The Script-task process element is a system action that executes the C# code and facilitates its interaction with other elements of the business-process. Use this element to implement logic that the standard process elements cannot provide, for example:
-
complex computations
-
processing records in bulk
-
looping
-
other tasks that are hard to implement using the stadard designer elements
-
as a replacement to a sequence of several and more Formula elements.
Follow the guidelines below to work with the Script task element.
-
Maintain the code structure. Test the element after saving by running the business process. The correctness of the code and the element’s performance depend on the code quality and the developer’s qualification.
-
Comment the main blocks of code and tasks performed by the Script task element to explain the function, purpose, and effects of each code part. This helps users better understand what the process does, and facilitates grasping the process workflow by developers.
-
Specify the exact names of third-party schemas when using them. Follow these guidelines when coding third-party schemas.
-
Avoid temporary fixes, since non-standardized code impairs the ability to maintain it. When process errors are encountered, make sure they are fixed correctly.
-
End the code in Script task element with return true; line.
To edit the script code, double-click the element on the diagram. The element setup area will open, where you can enter and edit the script code (Fig. 1).
– expand the script code window.
– collapse the script code window.
– search text in the script code.
– show the hidden symbols in the text code (for example, spaces, tabulations).
Get and Set methods
All new business processes in Creatio are interpreted. Use the Get and Set methods (Fig. 2) to reference the parameter values of an interpreted process.
The Get method returns the value of an item or process.
Method signature:
T — parameter value type.
path — a string that specifies the path to a parameter or property. The path is built according to these rules:
-
“parameter name”
-
“property name”
-
“element name.parameter name”
-
“element name.property name”
The Set method sets the value of an item or process.
Method signature:
value — the specified value.
path — a string that specifies the path to a parameter or property. The path is built according to the rules described above for the Get method:
“T” – a generic type parameter not specific to a particular data type that accepts the passed type value. Conversion between Creatio and C# parameters is shown in the table below.
Conversion between Creatio and C# parameters
Creatio parameter type | C# parameter type |
---|---|
Integer | int |
Decimal (0.00000001) | decimal |
Decimal (0.0001) | |
Decimal (0.001) | |
Decimal (0.01) | |
Decimal (0.1) | |
Currency | |
Date/time | DateTime |
Date | |
Time | |
Unique identifier | Guid |
Lookup | |
Boolean | bool |
Text (50 characters) | string |
Text (250 characters) | |
Text (500 characters) | |
Unlimited length text | |
Non-localizable string | |
Collection of values | IObjectList and any classes that implement these interfaces |
Collection of records | ICompositeObjectList<ICompositeObject> and any classes that implement these interfaces |