Here are some tips / good practices to improve the management of your scripts.
Script variables VS variables Iterop
In script, all Iterop variables are accessible thanks to their id. But in a process not all script variables are accessible. Thus, to differentiate them, we recommend to respect a writing standard for scripts. Here is ours
- For a internal variable javaScript we recommend the Camel Case preceded by the prefix _.
- Format: _xxxxXxxxxxxxxXxxx
- For a process we use a variable in two parts, the first one, the name of the script task in Camel Case and the second one, the name of the argument also in Camel Case.
- Format: myScript_MyVariable_Tasks
Description / Annotation
It is not a matter of explaining line by line what the code does, far from it. But in some complex cases, a little inline comment is sometimes useful.
To make your code as readable as possible, remember and apply the following points:
- Respect the naming and structure rules
- A structured and clear code needs little or no comment.
- The commentary should be limited to elements that are difficult to understand.
- The comment should not describe/explain the code at a technical level.
Setting a breakpoint in a script
It is possible to put some kind of breakpoint in a script. In reality this will generate an error but the error description will return what you want: So you can see the contents of a variable in the middle of a script.
var _content = JSON.parse(start_variableComponent) throw JSON.stringify(_content[0]) var _content[0].value = ....
This script puts a breakpoint on line 2 and returns the contents of the first line of the compound variable filled in the start.
Manipulating Iterop lists in scripts
Iterop lists are actually stored as strings of characters separated by “##”.
element 1##element 2##element 3
Since it is more comfortable to work with different elements as a js list than as a string, here’s how to switch from one to the other:
var _listeDesElement = start_liste.split("##"); var _listeSubFromatIterop = _listeDesElement.join("##");
Displaying a repository in a compound variable
Manipulating Iterop lists in scripts