Using the UiPath.Activities.API package from the Official feed (https://www.myget.org/F/workflow
], you can set Studio to show activities that match the custom activity's scope at search.
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);
}
}
Updated 2 years ago