sdk
latest
false
Developer Guide
Last updated Oct 25, 2024

Prioritize Activities by Scope

Using the UiPath.Activities.API package from the Official feed (https://pkgs.dev.azure.com/uipath/Public.Feeds/_packaging/UiPath-Official/nuget/v3/index.json), you can set Studio to show activities that match the custom activity's scope at search. For information on how to use the API, see Studio Activities SDK.

Therefore, when clicking the icon inside a custom activity the Command Palette offers suggestions of activities which fit the current scope.

To achieve this, use the IScopedActivitiesService interface, with the following methods:
  • SetScopedActivity - Adds a pair made from a scope activity and an activity that is suitable to that scope.
  • SetScopedActivities - Adds a list of suitable activity types to the specified scope type.

Below is an example of how these methods should be used inside your custom activity:

public void Initialize(object argument)
        {
            try
            {
                if (!(argument is IWorkflowDesignApi api))
                {
                    return;
                }
                if (api.HasFeature(DesignFeatureKeys.ScopedActivities))
                {
                    api.ScopedActivitiesService.SetScopedActivities(typeof(FirstScopeActivity), new List<Type>() { typeof(FirstChildActivity), typeof(SecondChildActivity) });
                    api.ScopedActivitiesService.SetScopedActivity(typeof(SecondScopeActivity), typeof(ThirdChildActivity));
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
            }
        }public void Initialize(object argument)
        {
            try
            {
                if (!(argument is IWorkflowDesignApi api))
                {
                    return;
                }
                if (api.HasFeature(DesignFeatureKeys.ScopedActivities))
                {
                    api.ScopedActivitiesService.SetScopedActivities(typeof(FirstScopeActivity), new List<Type>() { typeof(FirstChildActivity), typeof(SecondChildActivity) });
                    api.ScopedActivitiesService.SetScopedActivity(typeof(SecondScopeActivity), typeof(ThirdChildActivity));
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
            }
        }

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.