Working with system variables

The ITSMA Service Management System Language provides different types of variables identified by their names. Variables of each type have different behaviors and scopes, for example, local to RAD application, global inside RAD thread, and global inside session. For more information, see Variable pools. This may affect the following JavaScript implementation:

  • Function calls in JavaScript use call-by-reference. That is, when calling a function with a variable as parameter, the value of the variable is NOT copied, but only referenced.
  • Calling doAction() function from JavaScript will call the Document Engine, and by this MAY CHANGE non-local variables such as $file. That is, when calling a JavaScript function from Format Control, and calling doAction() inside this function might corrupt the $file variable when control is returned to Format Control.

Example of the issue

The following is an example of this issue:

function test()
{
var file = new SCFile("probsummary");
 
var rc = file.doSelect('number="IM10001"');
 
if (rc == RC_SUCCESS)
{
file.job_name="test";
 
file.doAction("save");
}
else
{
print("JS testFC.test():Select of incident IM10001 failed! ");
}
 
}

 

Format Control "device", tab page "Javascript" to be executed on display:

print("1. Filename:"+system.functions.filename(vars.$file));
system.library.testFC.test();
print("2. Filename:"+system.functions.filename(vars.$file));

To reproduce the issue, follow these steps:

  1. In the System Navigator, navigate to Configuration Management > Resources > Search CIs.
  2. The following messages appear:

    2. Filename:probsummary
    US/Mountain 01/31/14 09:35:29: Incident IM10001 has been updated by falcon
    1. Filename:device

Recommended implementation

Back up the $file variable before the function call, and restore afterwards. Change the Format Control "device" implementation in the example above like this:

print("1. Filename:"+system.functions.filename(vars.$file));
var backup = new SCFile(system.functions.filename(vars.$file));
var rc = system.functions.fduplicate(backup,vars.$file);
system.library.testFC.test();
vars.$file=backup;
print("2. Filename:"+system.functions.filename(vars.$file));