2

I recently started using UiPath for creating automatic processes at work. I've tried my hand at creating custom activities.

One of these activities are called AddToDictionary. It's generic because the user needs to specify the KeyValPair types, that the dictionary will store.

    [DisplayName("Add to dictionary")]
    [Description("Adds a KeyValuePair to a dictionary.")]
    public sealed class AddToDictionary<TKey, TValue> : CodeActivity
    {
        [Category("Input")]
        [RequiredArgument]
        [DisplayName("Dictionary target")]
        [Description("The target dictionary, which the KeyValuePair will be added to.")]
        public InArgument<Dictionary<TKey, TValue>> Dictionary { get; set; }

        [Category("Input")]
        [RequiredArgument]
        [Description("The key object, which will be added to the target dictionary")]
        public InArgument<TKey> Key { get; set; }

        [Category("Input")]
        [RequiredArgument]
        [Description("The value object, which will be added to the target dictionary")]
        public InArgument<TValue> Value { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            var key = Key.Get(context);
            var value = Value.Get(context);
            Dictionary.Get(context).Add(key, value);
        }
    } 

Now the activity is working fine in UiPath, No problem there. But when i drag the activity into my workflow, a window pops up, asking for the types. Now what i would much rather have is a dropdown-choose-your-own-type sort of thing, in the right side properties window.

I've been scouring the internet for open source code, but found nothing so far.

  • To get a drop down you can use code from https://forum.uipath.com/t/dropdown-display-names-in-properties-of-custom-activity-friendly-names-to-enum-dropdown-in-custom-activity/113590?u=conorsmalley or https://stackoverflow.com/questions/2724356/binding-data-to-combobox-in-custom-activity-designer however I'm unsure how you would bind it to object types – Conor Oct 01 '19 at 14:19
  • The generic types need to be resolved before the activity is put to the canvas. That is why the popup asks you the types. – Paras Gera Oct 04 '19 at 06:12

0 Answers0