Invoke Method -What possible functions? -Method NAME

Hi
I want to better understand the activity of the Invoke method
What possible functions? -Method NAME
Why is it useful?
Explanations of the active properties
Thank you
Tamar

let me ask you one question.

Suppose you have a list (numList) of numbers (int32) i.e., numList = {1,2,3,4,5} and you want to add another number say 100 to this list so that the list becomes numList = {1, 2, 3, 4, 5, 100}. How wil you perform this operation in UiPath without invoke code activity?

Enabled by ADD TO COLLECTION
But I realized that it better is Invoke METHOD
Can you send me examples of how to work with this asset?
Thanks!!

another question

how to get list of all the files(full path) and folders(full path) present in a directory?

invoke method example.xaml (5.4 KB)

True it does not exist
Do you have the option to send me a sample for each function? What functions are there?
And why is it more effective?
Thanks

I am not sure but the functions which do not return any value are to be used with invoke method.

I did not understand,
For example, if I want to add to the list, subtract from any number any value etc. How do I work with it?

I have given you the example workflow above

Try to analyse it. Recreate it by yourself and let me know if you do not understand it.

Using an assign activity requires from right Side that a value is returned.

There are Methods available of following types

  • Functions - returning a value
  • Sub, so called subroutine - not returning a value

So in cases WE want to execute a Method which is of Type sub, WE do use an invoke Method for this

While development WE can Check the intellisense Suggestion in which Method Type WE do get. Otherwise WE do refer to the formal docu references.

Fazit. Add Method from a list ist of methodtype sub. AS IT has no return value, WE do use invoke Method ( or the Activity add to collection)

1 Like

Can you send me an example of this?
I did not understand enough

I understood the example you sent,
And I also realized that the Invoke method must return value,
If I want to add a value to an INT variable or subtract etc. how do I do that?

this can be done simply by assign activity.

num = num + 2

or

num = num - 2

Yes, that’s how I know
But I want to use the invoke method
So when is it useful and when not?

Hi,

Assign activity may be considered as a subset of Invoke Method.
Assign activity can only be used with expressions or methods that have a return value. Instead, it is very readable than Invoke Method.
Invoke Method, on the other hand, can be used even no return value. It also supports ref and out arguments and get its value, that are not supported in Assign activity.
Therefore, expressions or methods that have a return value usually use an Assign activity for readability. And others (for example, have ref or out arguments and want to get its value, and/or have no return value) is used Invoke Method.

Regards,

1 Like

Thank you very much for the explanation
Regarding the active of the INVOKE can you send me more examples in what is it useful?
For example if I want to add a value to a variable or operations that do not return a value
Thanks

its opposite:

  • Statements used within assign activity right side hast to return a value
  • Invoke method can call a method without return value

An example could be the SetOrdinal Method from a datacolumn variable:
grafik

we do see that it is a sub (subroutine) and the method will not return a value.

It will lead to compiler validation error:
grafik

translated: Statement will not return a value

so we use an invoke method:
grafik
with following parameters:

And it will work. The SetOrdinal method and its allowed parameters we can check in the corresponding .Net docu

1 Like

Okay so what I understand is,
That the ASSIGN asset must return value
However in the active use of INVOKE METHOD it is not mandatory

Can you send me the example you did and an explanation of it?
invoke METHOD and if you can more examples please use

Thank u

please help me
thank u

It’s nice but it does not tell me too much
This activity exists so that certain things can be done with it
The question is what can be done other than SetOrdinal

Thank you