Workflow Script Examples
The following script examples are intended for example purposes only and do not necessarily perform any commonly used functions that users may use in their production environments.
Example 1
In this example, there is a subprocess local variable called Field1 and another called Field2. In the code activity configuration the parameter Field1 will be bound to the parameter called InitialValue. The Field2 field will be bound to a parameter called AdjustedValue. The following is an example of how this appears in the code activity editor:
AdjustedValue = InitialValue * 2 + 40;
If (AdjustedValue > 100) Then
AdjustedValue = 100
End If
Upon running this script in an instance of a workflow, Field2 will be set to the value of AdjustedValue.
Example 2
In this example there are 2 parameters in the code activity: an Integer called InitialValue, which could be bound to a local variable or activity property, and a boolean called PerformFunction which is also bound to a local variable and serves as an ouput. The code snippet will perform a simple calculation on InitialValue and if the value is greater than 100, PerformFunction is set to true, which in turn, could drive a different execution path.
Dim adjustedValue As int32
adjustedValue = InitialValue * 2 + 40;
If (adjustedValue > 100) Then
PerformFunction = True
Else
PerformFunction = False
End If
Example 3
In this example, you can use a static string method to compare a variable to the string “Done”. If they match then the code snippet will exit (using the Return statement). Otherwise, it will carry on and do something else indicated by the comment.
If String.Equals(MyString, "Done") Then
Return
End If
' Comment: Do some more stuff here..