Better Invoke Method For One-Liners

Currently the Invoke Method is used in order to use methods on objects, like when a given developer has a List<String> and wishes to use List.Add to append an item to the end. Invoke Method is clumsy however and makes the intent harder to figure out by simply looking at it.

I would ask that a new activity be made that will take a line of code and run it. That way, in the above example, the developer can simply use their List, let’s say “InvoiceNumbers”, and do InvoiceNumbers.Add(Invoice) which is much easier to read and understand.

This is also similar to the Invoke Code activity, but, instead of requiring input and output arguments, it is run within the current scope. The Invoke Code activity, while having this sort of capability, is also unwieldy to use due to the fact that it requires arguments.

Completely agree. It would be much easier to call LINQ methods on Enumerable variables if it did not require adding an invoke code activity and configuring the in/out variable arguments. Currently it seems like the best way to do something like this is via an assign activity, but that requires assigning a value to a variable, which isn’t possible for list methods that return void like Add as you mentioned.

2 Likes

@loginerror @Pablito, Could you please also add this to the internal tracker?

1 Like

Hi,
Thank you for your suggestion. I added it to our internal ideas tracker for our team to consider.

I agree, the InvokeMethod activity is clumsy. Besides, the parameters of the concerned method deeply hidden in the activity’s interface. Related: How to execute no data return functions in UIPath Studio.
You might work around this by creating a Void (of type object) variable and use the the Assign activity:

image

image

Note: this will not work for a method that doesn’t return a value as this will cause the following error:

expression does not produce a value

(I haven’t found a work around for this …yet)

1 Like

Any update regarding this feature request? Invoke Method is overcomplicated when all we really want is just an Assign activity without the assign part.

image

1 Like

This feedback has been reviewed and it’s on our list :slight_smile:
But can’t tell you any exact date.

1 Like