To customize the behaviour of the processes, scripting action can be used.


When a script is interpreted, an object is passed to this script to provide access to the Runtime Engine features. This Context object is accessed using the __ctx__ alias. 

This object provides a list of methods for manipulating variables and values as well as a return value used for code substitution and condition evaluation.


... more on Semarchy xDI Documentation > Design Integration Flows > Work With Processes > Scripting



The method "Get Variable List" (getLstVariablesByName) returns a list of variables corresponding to certain criteria. 

See documentation for the full description


This method can fit to a use case of error management in which the information of the action in error needs to be published in sessions or store in database.



In below example, the first variable related to error code, path and message will be published in the process root sessions variables using rhino language :



Scripting Publish ERROR 

  • Action expression :
    errorsOnly = true;
    err = __ctx__.getLstVariablesByName("CORE_RET_MESS", "../subprocess", errorsOnly);
    
    // Build Error String
    errorPath = "";
    errorString = "";
    
    if (err.size() > 0) {
        errorPath = err.get(0).name;
        errorString = err.get(0).value;
    }
    
    // Publish to variables on the root process
    __ctx__.publishVariable("~/ErrorPath", errorPath);
    __ctx__.publishVariable("~/ErrorString", errorString);
    __ctx__.publishVariable("~/ErrorRetCode", "${../subprocess/CORE_RET_CODE}$");


  • SCRIPTING_LANGUAGE parameter value :
    rhino


Variable vue :