stay Camunda in , The script task is an automatic activity , When the process executes a script task , Related scripts are automatically executed .camunda Support is mostly compatible JSR-223 Script engine implementation , such as Groovy, JavaScript, JRuby and Jython.
This paper focuses on the description based on JavaScript Script engine configuration for Camunda Script Services , Complete script based automatic calculation , And return the calculation result to the process variable .
One 、 Design flow chart
The following are the key configuration items of the script node :
The settings of the return value of the script calculation result are 2 Ways of planting :
One is to pass. result Variable Property settings . By specifying the process variable name as the... Defined by the script task camunda:resultVariable The text value of the property , You can assign the return value of a script task to a pre-existing process variable or a new process variable . Any existing value of a specific process variable will be overwritten by the result value of the script execution . When no result variable name is specified , Script result values will be ignored .
Two is through execution.setVariable(" Variable name "," A variable's value "); How to set , You can set multiple variables in a script , More flexible .
The following is complete BPMN Model file :
Two 、 Initiate process testing
Sign in :http://localhost:8080/camunda/app/admin/default/#/login
1、 Initiate process , Enter process variables , The following script node calculation requires these two process variables
2、 After submitting the process , View flowchart ,Script The script node has been successfully executed
3、 View the process variables in the form ,Script The return value calculated by the script node has been written successfully .
More reference :
https://docs.camunda.org/manual/7.15/reference/bpmn20/tasks/script-task/