RPA之家(www.rpazj.com)是中国具有影响力的RPA垂直交流社区,社区汇聚了RPA领域的各类从业人员。其中包括RPA开发工程师、售前工程师、业务分析师、架构师、运维工程师、项目管理、项目负责人、企业高管、HR等多种角色。社区提供了各种丰富的教程、资讯、文章、问答、招聘、活动、项目等供大家一起交流和成长。
UiPath.Core.Activities.InvokeCode
Synchronously invokes VB.NET or C# code, optionally passing it a list of input arguments. This activity can also return out arguments to the caller workflow.
属性
输入
- “参数”- 可以向调用代码传递的参数。
- Code - The code that is to be invoked. This field supports only strings and
String
variables. - Language - A drop-down menu that specifies what language the invoked code is written in. The available options are VBNet and CSharp.
Common
- DisplayName - The display name of the activity.
- ContinueOnError - Specifies if the automation should continue even when the activity throws an error. This field only supports Boolean values (True, False). The default value is False. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set to True, the execution of the project continues regardless of any error.
Misc
- Private - If selected, the values of variables and arguments are no longer logged at Verbose level.
Example of Using the Invoke Code Activity
The Invoke Code activity is used for directly calling vb.net
code from the UiPath platform. Using this activity you can specify exactly what code to be executed and what arguments to be passed to and from the activity.
此自动化流程的构建方法如下:
- 打开 Studio ,创建一个新“流程”。
- Drag a Sequence to the Workflow Designer.
- 创建以下变量:
变量名称 | 变量类型 | 默认值 |
---|---|---|
ExampleInArgument | 字符串 | - |
OutValue | Int32 | - |
- Drag an Assign activity inside the sequence container.
- Add the variable
ExampleInArgument
in the To field and the expression"Example for In Arguments"
in the Value field.
- Add the variable
- Add an Invoke Code activity below the Assign activity.
- Select the Edit Code button for introducing the desired code.
- Type the code in the Code Editor window. For this example we have added a simple code that writes a string on the screen. Here is the code we have used:
VB.NET
Dim TextToWrite As String TextToWrite = "Example" Console.WriteLine(TextToWrite)
- Select the OK button to close the Code Editor window.
- Select the Edit Arguments button and create the following arguments:
Argument Name | Argument Direction | 参数类型 | 参数值 |
---|---|---|---|
ExampleInArgument | 输入 | 字符串 | ExampleInArgument |
ExampleOutArgument | Out | Int32 | OutValue |
- Select the OK button to close the Invoked code arguments window.
- Place a Write Line activity under the Invoke Code activity.
- Add the expression
OutValue.ToString
in the Text field.
- Add the expression
- Run the process. The robot displays in the Output panel the code and arguments specified by you in the Invoke Code activity.