InvokeMethod

The 'Invoke Method' activity is a powerful tool in workflow automation, enabling the
execution of a public method from an external DLL within your process. This feature
is especially valuable when you need to integrate custom functionality or utilize
external libraries for specific tasks.

For detailed information about external DLLs, click here.

Technical Reference

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MISC

DisplayName: Displays the name of the activity. The activity name can be customized, which aids in troubleshooting.

GenericTypeArguments: This parameter is used to provide specific 'GenericTypeArguments’ required for executing a public method from the external DLL. It can be left empty if the generic type is not required by the DLL.

MethodName: Specify the “Method name” that needs to be called during the execution of a public method from the External DLL. This field accepts only “String” datatype.

Parameters: This parameter helps you to provide the “inputs” that are required to pass during the execution of the DLL.

This field accepts collection of argument type.   

Result: It allows you to view the activity's output, which is the result of executing the 'DLL'. It returns the value as specified datatype in the “Out” Argument. To get detailed information, refer the steps below in the example.

RunAsynchronously: Check this box to determine if the DLL should be executed asynchronously. This allows the method to run without waiting for the operation to finish. If left unchecked, it will block the method until the operation is completed.

TargetObject: This parameter helps you to call methods on object. Specify the “Object” to invoke during the execution of the DLL. This field accepts the value only in “String” datatype. 

TargetType: Specify the “Datatype” of the DLL that is invoked here. This parameter accepts only if the method is static.

Represents mandatory fields to execute the workflow

Here’s an example of how the “InvokeMethod” activity is used in workflow –

The following example helps you to understand how the DLL is added and utilized
into the workflow. 

In this case, I have added a sample DLL for automating 'Calculation' functionality.
This method requires two input values for automation.

Here I have already added the DLL; refer to the steps for adding it.

Steps to execute a bot

1.       Create a solution named “DLLDOC” or open an existing solution.

2.       Drag and drop the “Invoke Method” activity from the “Invoke” feature to the
workflow.

a.       It is used to invoke the method from external DLLs. Here we are performing
“Addition” method from the DLL.

b.       Now, choose the “Target type” as “Browse for types.”

 i.            In this case, we are choosing the “datatype” of added DLL from the
“.Net window”.

ii.            The datatype will be added to the “.NET Window” once the DLL has been
invoked
to the solution.

iii.            The .NET window will appear on the screen, and you can select the datatype
of the DLL from here. I am choosing the type as “Calculation” here.

3.       Next, moving to the “MethodName” property.

a.       In this case, I am going to use the method name as “Add” from the DLL.

4.       Now, navigating to the “Parameters” in the properties to provide the input
values to perform the method.

a.       Choose the “three dots” and the “Arguments panel” will appear on the screen.

b.       I am choosing the “direction” of the input values as “IN” here as the values
are passed as input to the method during the execution.

c.       In this case, we require only “INTEGER” datatype to perform the addition
method. Choosing the “Arguments type” as “INT32” from the drop-down for
both the input values.

d.       Now, I am providing the first value as “12” in the “Value” field as input here.

e.       And the second value as “56” in the box and then click on “Ok” button.

f.        Now the values to perform the “Addition” method has been added.

5.       Next, to view the output of the method performed, we are going to declare
an “Out” argument.

a.       Navigate to the “Arguments” panel,

b.       Here I am using the “ArgumentName” as “FinalResult” and choose the
“AgurmentType” as “Int32” as the “Output” will be in numbers.

c.       Next, Choose the argument type as “Out” as it is used only to return output.

6.       Next, we are providing the declared argument to the “Result” property in
the activity.

a.       It is used to view the output of the method performed with the DLL.

b.        Navigate to the property and providing the value as “FinalResult” here.

7.       Drag and drop the 'Write Line' activity to view the result of InvokeMethod”.
It will return the output of the method.

a.       Enter the input text as “FinalResult.ToString”.

b.       The “.ToString” extension is advised to use along with any other data types
other than string format. It converts any data type into string.

8.       Now, execute the workflow.

The bot will execute the “Add” method with provided input values and returns the
output. Below is the sample of the output of the workflow execution.