Group arguments in input category - Custom Activity

Hi!

I find myself developing a Custom Activity from Visual Studio (C#) with the CodeActivity class, and I was able to create the .nupkg and import it as an Activity in Uipath.

I have 2 requirements, the first one is that some input arguments were dependent on a parent argument, as in the following image:

Image property is parent of: Accuracy, image, Profile but it is at the same level of ClippingRegion, MouseButton and Selector.

image

This attribute has the ability to expand or contract and there can be several of this style.

And the second one is, how can I customize the input data type to be a dropdown list, a checkbox, etc?

If you have any documentation you can share with me I would appreciate it.

Hi,

Do you mean you want to create Image category and dropdown menu? If so, can you try as the following, for example?

[Category("Image")]
public System.IO.SearchOption SearchOption { get; set; }

If we set enum type as property, it will automatically be dropdown. (Please note that it’s static)

Regards,

Hi,

From the drop down list it is clear to me how it works, that solves my second question!

But as for the first one I’m still in doubt, I understand that using [Category("Image")] creates a new category as Input, Output or Misc, my need is that the input arguments (public InArgument<> Accuracy) Accuracy, Image and Profile are dependent on the Image input argument.

The Image argument in this case belongs to the Input category

image

Regards,

Hi,

Can you try as the following?

First of all, create class for sub-category, let’s say Sub , as the following

[TypeConverter(typeof(ExpandableObjectConverter))]
[Category("Options")]
public class Sub
{
    [LocalizedDisplayName("SubMenu")]
    public InArgument<string> SubMenu { get; set; }

    [LocalizedDisplayName("SubMenu2")]
    public InArgument<string> SubMenu2 { get; set; }

	public Sub()
	{
		this.SubMenu = new InArgument<string>();
		this.SubMenu2 = new InArgument<string>();
	}

	public void CacheMetadata(CodeActivityMetadata metadata)
	{
		if (this.SubMenu != null)
		{
			RuntimeArgument argument = new RuntimeArgument("SubMenu", typeof(string), ArgumentDirection.In, false);
			metadata.AddArgument(argument);
			metadata.Bind(this.SubMenu, argument);
		}
		if (this.SubMenu2 != null)
		{
			RuntimeArgument argument2 = new RuntimeArgument("SubMenu2", typeof(string), ArgumentDirection.In, false);
			metadata.AddArgument(argument2);
			metadata.Bind(this.SubMenu2, argument2);
		}
	}
}

Then, add argument for Sub and CacheMetadata method into main activity class, as the following

    [LocalizedCategory("Options")]
    public Sub Sub { get; set; }

    // Constractor
    public MainActivity()
    {
        this.Sub = new Sub();
    }

    protected override void CacheMetadata(CodeActivityMetadata metadata)
    {
        base.CacheMetadata(metadata);
        if (this.Sub != null)
        {
            this.Sub.CacheMetadata(metadata);
        }
    }

This will be as the following.

image

Hope this helps you.

Regards,

1 Like

Hi @Yoichi!

Wow, That’s exactly what I needed!
Thank you so much for all your help!!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.