List.add Method does not work

Hi guys,

I try to add a String to a list with the list.add method but the error occurs “Expression does not produce a value”.
I know it could use the add to collection activity but I want to know why it does not work with the simple add-Method. As you can see in the screens there is even a code suggestion with add but it don’t work.
Does Uipath not support that or did I something wrong?

Thanks and regards

You need to use the cumbersome Invoke Method activity instead.

1 Like

Thank you @ptrobot

So that means, Uipath does not support the direct code way, right?

No, it’s a feature we have requested. It’s on their To Do-list. Vote for this feature here: Better Invoke Method For One-Liners

a sub (subroutine) is not returning a value (as functions are doing it). That’s why you do see the error. As nothing is returned, there is no value that can be used for the assignment.

Using a sub -> invoke method

Ok I did