Developer
Description
Use this activity to invoke your custom VB.NET code. You can pass or return arguments to the workflow that executes the activity.
To enter or modify the code:
-
Click Edit Code.
-
In the VB Code Editor dialog box, enter the code
. -
Click Validate Code.
-
Review the Result pane for errors.
Properties
Analyst
- Description: Optional text for documentation purposes.
Common
-
Continue On Error: Continues the execution of the workflow even if an error occurs during the execution of the activity.
-
Delay Before: Delay time in milliseconds before the activity is executed. The default value is 250 milliseconds.
-
Delay After: Delay time in milliseconds after executing of the activity. The default value is 250 milliseconds.
-
Disable Log: Disables the logging functionality for this activity.
-
Disable Protocol: Disables the protocol functionality for this activity.
-
Exclude from Global Delay: Excludes this activity from the Global Delay functionality.
-
Timeout: Duration in milliseconds in which the activity tries to execute.
Input
-
Arguments: The arguments you want to pass to the invoked VB.NET code. As always when working with variables, make sure you have selected the correct variable type. In addition, you must specify the direction of the mapping.
- In: Pass the argument to the Invoke VB Code activity.
- Out: Passing the variable from the Invoke VB Code activity to the workflow.
- InOut: Both directions are possible.
- Code: The VB.NET code to be invoked. The section use case/example contains some sample code. Note that you cannot define your own functions or subroutines here.
For more information, see the Visual Basic Text Expressions chapter in the Hyland RPA Designer documentation.
Example
This VB.NET code example has two input arguments, _dt of type DataTable and _fileLoc of type String, converts the DataTable to a single string by separating all row values by commas and inserting a line break for each new row, and writes the resulting string into a CSV file.
Before executing the Invoke VB Code activity, you need to create a data table with some values and specify the file path including the file name, for example %userprofile%\desktop\test.csv, as both arguments will then be passed to the activity.
VB.NET code:
Dim sb As StringBuilder = New StringBuilder() Dim columnNames As IEnumerable(Of String) = _dt.Columns.Cast(Of DataColumn).Select(Function(column) column.ColumnName) sb.AppendLine(String.Join(",", columnNames)) For Each row As DataRow In _dt.Rows Dim fields As IEnumerable(Of String) = row.ItemArray.Select(Function(field) field.ToString()) sb.AppendLine(String.Join(",", fields)) Next File.WriteAllText(_fileLoc, sb.ToString())
Tips and Tricks
- Any namespaces referenced in your VB.NET code need to be imported first. You can add new namespaces on the Imports tab of the Variable Management. For more information, see "Variable Management" in the Hyland RPA Designer Help.
Troubleshooting
-
A lot of different exceptions can occur based on the specific code you wrote. For more information on common exceptions, see "Handling and throwing exceptions in .NET" on docs.microsoft.com.
See also
- Invoke C#
- "Custom Activity Guide" in the Hyland RPA Help