How to pass value from one variable to another using JavaScript in CA Workload Automation DE
search cancel

How to pass value from one variable to another using JavaScript in CA Workload Automation DE

book

Article ID: 98250

calendar_today

Updated On:

Products

DSERIES- SERVER CA Workload Automation DE - System Agent (dSeries)

Issue/Introduction

Using JavaScript you can convert variables, including builtin and pass the value to another variable.  This may be helpful in setting variable for Alerts and builtin commands.

How to pass value from one variable to another using JavaScript in CA Workload Automation DE?

Environment

CA Workload Automation DE 11.3.x, R12.x

Resolution

Here is an example of a variable trying to pass a value of another variable. 


//eventname = 'USER1'
//Split on I and take second value, 1.  First split place will be 0.
var myvar = APPL._eventprefix.split('I')[1]; 
//toString method
APPL.VAR2 = myvar.toString();



The result can used be in builtin DE command(s) like this:


if (APPL.VAR2 == 'T') 
{resetResourceProperty('SOMERESOURCE1','Availability','1');  } 
else if 
(APPL.VAR2 == 'SOMETHINGELSE') 
{resetResourceProperty('SOMERESOURCE2','Availability','0'); }




 

Additional Information

Note: Make sure the initial variable has a value or resolves to some value.  If it results in a blank, then you will see the following error:
Error executing application-level runtime JavaScript script to_string for application MY_APPLICATION. 
The error is: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "toString" of undefined (<wascope>#3)