Script

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
Information

Camel case notation consists of writing a set of words by linking them together without spaces or punctuation, and capitalizing the first letter of each term.

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.

Mise en garde

Not too much, not enough. If a script is difficult to understand it’s probably because it should be simplified or the variables are not clear enough.

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.

Mise en garde

Everything that takes place before the throw (except execution.setVariable) is actually executed: So if you make an addRow in a business repository: the line will be added even if the script is stopped.

Attention

We will have to think about removing this breakpoint before putting the process into production.

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

Updated on 13 November 2020

Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support