There are many cases where you need to process strings in the middle of a flow, such as changing the notation of a URL to be lowercase, or adding an honorific title to a customer name. The [Script Task] can be utilized for automatically processing String-type Business data. It requires knowledge of ECMA Script (server side JavaScript).
1. Overview of the String Processing Mechanism
- a. String literal (Primitive Value)
- You can use JavaScript's string methods
- b. String object
- You can also use Java's string methods, with "new java.lang.String()"
- It is processed by the JavaScript execution engine "GraalJS" that is built into the workflow platform (M230)
- Be careful when using methods with different behaviours (for example, regular expressions, arrays, etc.)
2. Overview of Practical Examples of String Processing
- a. Concatenation
- Connecting string to string
- b. Substring
- Extracting a portion of a string
- c. Replacement
- Replacement of text letter case, replacement by Regular Expression, etc.
- [Update Data] can also be used for "a. Concatenation" (M227)
- In accordance with ECMAScript provisions a plus sign "+" will always be the string concatenator when either one is a string
3. Configure ECMAScript on a Script Task
- 1. Write a function that references Business Data
- Use a unique reference expression; For example: var tmp = engine.findDataByNumber("99")
- 2. Write a script for processing a string
- Write a string manipulation script that conforms to ECMA.
- 3. Write a function for overwriting Business Data
- Use a unique assignment expression; For example: engine.setDataByNumber("99",tmp)
- Assignment and overwriting of Business Data will be performed collectively after the script processing is completed
- Assignment and overwriting will not be performed in the event of an error (go to the next processing Step)
- The processing time of scripts is limited to 30 seconds (this will vary a little according to the load condition)
R2300: Java Classes available in Script Task
R2301: Script Data Retrieving / Assignment
BPMN Icons: Script Task
Comments
0 comments
Please sign in to leave a comment.