If you want to automate a Processing step to, for example, obtain the number of characters and the hash value, you have to write scripts using a [Script Task]. If you need to use the same [Script Task] in different places you should consider packaging the script as an [Add-on XML]. (Service-Task Addon)
1. Overview of the Advantages of Creating Addon XML (Packaging)
- a. Aspects of IT skill requirements (compared with a Script Task)
- A flow designer who does not have script knowledge should be capable of process automation as well.
- b. Aspects of the modelling cost (compared with Script Task)
- There will be no need to write the same script repeatedly.
- The boundary between the IT Department's and the Process owner's responsibilities should be considered
- Go to M415 for more info on how to import a pre-existing [Addon XML]
- Go to M416 (Bottom of this page) or to "Download" in M415 for Sample codes
2. Determine the Package Name
- a. Aspects of output by auto-step
- E.g. contents of data to be stored, contents of external system auto-operation, etc.
- b. Aspects of input by auto-step
- E.g. business data to be inspected, data name in external system to be referenced, etc.
- You can set the file name of the package file (Add-on XML) with 52 characters or less.
- The name of the auto-step (Service Task) is defined in
<label>
element (64 characters max.) - Sample of a:
<label>Random Number Generator</label>
- Sample of b:
<label>Weather Info Getter</label>
- You can define an overview in
<summary>
element (250 characters max.) - You can define the URL of the help page in
<help-page-url>
element (250 characters max.) - You can define the last modified date in
<last-modified>
element (YYYY-MM-DD)
3. Determine the Configuration Items Required
- a. Business Data Items which are to be referenced by the Step (SELECT)
- E.g. To write to Data A, To read Data B. etc.
- b. Fixed values used in the Step (TEXTFIELD, TEXTAREA, QUSER, OAUTH2)
- E.g. Maximum value: "100", Status: This Draft is at the "not yet approved" stage, etc.
- List configuration items with
<config>
which is a child element of<configs>
- You can list up to 20 configuration items using
<config>
- Mandatory element
<config>
can also be grouped with its parent element<tab>
(from v15.0) - When using the grouping element
<tab>
, the parent element (root element)<tabs>
is required - The
<config>
element can be shown or hidden depending on the values of other configuration items by specifying thedepends-on
attribute
R4160: Addon-XML Attributes of config element
R2272: Output of Strings via EL syntax
4. Determine Automatic Processing Behavior
- 1. Write a server-side script
- Write in ECMA code that can be used in the script Step (M230).
- Knowledge of ECMAScript (JavaScript) is required
- Using parts of Java classes is also possible
- Script is described between
<script><![CDATA[
and]]></script>
- Use the special method
configs.getObject("♦configName♦")
andconfigs.get("♦configName♦")
for referring to configconfigs.getObject("♦configName♦")
will return the following objects :- form-type="QUSER" : QuserView object
- form-type="SELECT" : ProcessDataDefinitionView object
- If typing in a text field with the config defined as editable="true": null
- configs.get("♦configName♦") will return the strings entered in the text field
configs.get("♦configName♦")
will return java.lang.String object
- Use
findData( ♦dataDef♦ )
andfindDataByNumber( "♦dataId♦" )
, etc. for referring to Business Data (M230) - Use
setData( ♦dataDef♦, ♦value♦ )
andsetDataByNumber( "♦dataId♦", ♦value♦ )
, etc. for updating Business Data (M230) - When setting the processing engine to "GraalJS"
<engine-type> 3 </ engine-type>
is specified<engine-type> 2 </ engine-type>
: GraalJS (Nashorn Compatible Mode) (Deprecated (Ver. 16.0))
- HTTP requests must be up to 10 per one automatic Task
R2300: Java Classes available in Script Task
R2301: Script Data Retrieving / Updating
Script Engine GraalJS (Nashorn Compatible Mode) Discontinued (April 2024)
5. Determine the Process Logo (Optional)
- 1. Prepare an image file
- Prepare a image file of less than 64px (JPEG, GIF, PNG only)
- 2. Encode to Base64
- Use converter software or a web service
- Define using the icon data
<icon>
element - The logo will be displayed upon placement using Drag & Drop
6. Support Multiple Languages (Optional)
- 1. Add label elements with the locale attribute
- Add
<label>
for as many languages as you need for your Workflow designers
- E.g. Configure
<label locale="es">Generador de Numeros aleatorios</label>
for Spanish designers - en(default), ja, de, es, fr, ko, pt, zh_CN
A. Sample of Addon XML
<?xml version="1.0" encoding="UTF-8"?><service-task-definition>
<label>#Number: Generate Random</label>
<summary>Generates a random number. When a token reaches this automated step, a numerical value within the specified range is generated each time. The decimal part is rounded down toward 0 according to the workflow data definition.</summary>
<license>(C) Questetra, Inc. (MIT License)</license>
<help-page-url>https://support.questetra.com/addons/number-generate-random-2021/</help-page-url>
<configs>
<config name="conf_Lower" required="true" el-enabled="true" form-type="TEXTFIELD">
<label>A: Set Lower Limit (e.g. "0", "-0.5")</label>
<config name="conf_Upper" required="true" el-enabled="true" form-type="TEXTFIELD">
<label>B: Set Upper Limit (e.g. "10", "0.5")</label>
</config>
<config name="conf_DataIdC" required="true" form-type="SELECT" select-data-type="DECIMAL">
<label>C: Select NUMERIC DATA for Generated Number (update)</label>
</config>
</configs>
<engine-type>3</engine-type>
<last-modified>2023-08-08</last-modified>
<script><![CDATA[// GraalJS Script (engine type: 3)
// GraalJS Script (engine type: 2)
// (c) 2021, Questetra, Inc. (the MIT License)
//////// START "main()" ////////
main();
function main(){
//// == Config Retrieving ==
const lower = configs.get( "conf_Lower" ) + ""; // config required
const upper = configs.get( "conf_Upper" ) + ""; // config required
const dataIdC = configs.get( "conf_DataIdC" ) + ""; // config required
// 'java.lang.String' (String Obj) to javascript primitive 'string'
// Design-time Config Format Check
const numLower = parseFloat( lower );
engine.log( " AutomatedTask Lower Limit: " + numLower );
const numUpper = parseFloat( upper );
engine.log( " AutomatedTask Upper Limit: " + numUpper );
if( isNaN(numLower) ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {Lower} is not a number \n" );
}
if( isNaN(numUpper) ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {Upper} is not a number \n" );
}
if( numLower > numUpper ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {Lower} is greater than {Upper} \n" );
}
//// == Data Retrieving ==
// nothing (This Service Task is a CREATE type)
//// == Calculating ==
let numDiff = numUpper - numLower;
let mathRand = Math.random(); // Math.random(): 0.00 to 0.99
engine.log( " AutomatedTask Math.random(): " + mathRand );
let numRand = mathRand * numDiff + numLower;
engine.log( " AutomatedTask Generated Random: " + numRand );
//// == Data Updating ==
engine.setDataByNumber( dataIdC, new java.math.BigDecimal( numRand ) );
} //////// END "main()" ////////
]]></script>
<icon>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAEWUlEQVRYR8WXXUiUWRjHf6+ObuOo
la6uYuuKKVvrGrkiSazlst4UBCFetH4QKjaTGKwgLN0UBIHSxm5B23jhepFpX7vQVb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GDDZIX
AoRQgLbmF+Z5PfeaWfes5Mq4axxbu01eVjprmQx1jUhTgTi1qqrLihn1VpxegBMdq+mowd6t8x7x
MiJdKxYduJJ3RZ76fdazyWcUthXS8arDO93LiiXd9S+j45nHqU6vZn3o+lVhEP4gTn+9/7pentdl
JEIMrmOhgn2f7MP2mY20jWlyFFNvpjAHm6USvJdwyhMPTlDbVatX3Md1LEL9PEi8dxMeIUxHyM/p
dsqZizvBMe7A/qddmtKK5fNBokUG8CRb1SyWB/t5kmnBa/oo/X86scpn+VIn1vCHiQZiTX+aeRJo
zX6c/gvKB5L6D2XHtzBjw0oRAAAAAElFTkSuQmCC
</icon>
</service-task-definition>
Please also see each Add-on XML file (Add-on example) that is publicly available.
Support site: Add Automatic Processing Process (Addon)
X. Blog Articles
- 2018-05-09: Using Log Output for Debugging of Script Task
Comments
0 comments
Please sign in to leave a comment.