CustomActivity - How to create depending input arguments?

Hi!
How can I define depending input arguments in Visual Studio for a CustomActivity? For example if I select a target in the drop-down additional arguments are shown up like element and selector. If null is selected the arguments are not shown.

I want to use a checkbox Single-Sign-On in my custom activity. If clicked, the arguments Username and Password should be hidden. If not, Username and Password should be editable.

Thank you in advance!

image

Hi, welcome to the community!
Since this is a coding question (not specific to UiPath), please check .NET documentation for better help:
https://docs.microsoft.com/en-us/dotnet/framework/windows-workflow-foundation/required-arguments-and-overload-groups

Thank you for the link. Didn’t know the Overload Groups.

In the meantime I found a solution with Reflection. BUT how can I refresh the PropertyGrid of UiPath? RefreshProperties.All is not refreshing the grid. I need to click on another property and then back to my custom property to see the change.

image

Thanks to this article: https://www.codeproject.com/Articles/152945/Enabling-disabling-properties-at-runtime-in-the-Pr

private void showDependendProperty(string name, bool visible)
    {
        PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.GetType())[name];
        BrowsableAttribute attribute = (BrowsableAttribute)descriptor.Attributes[typeof(BrowsableAttribute)];
        FieldInfo fieldToChange = attribute.GetType().GetField("browsable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        fieldToChange.SetValue(attribute, visible);
    }

    [Category("Login")]
    [RequiredArgument]
    [RefreshProperties(RefreshProperties.All)]
    public bool SingleSignOn
    {
        get
        { return _singleSignOn; }
        set
        {
            _singleSignOn = value;
            showDependendProperty("Account", !value);
            showDependendProperty("Password", !value);
        }
    }
    bool _singleSignOn = true;

    [Category("Login")]
    [Browsable(false)]
    public InArgument<string> Account { get; set; }

    [Category("Login")]
    [Browsable(false)]
    public InArgument<string> Password { get; set; }

I think your best best is not about refresh, but managing the properties value changes:

1 Like

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