In Business rule and able to assign value to an object using current.variable

rvranjan_99
Tera Contributor

When  I logging the current.variables.environment then it is giving correct value but  when

var x={

    "environment":current.variables.environment

}

 

then  it is giving

{

"environment":{}

}

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

You can use this approach instead:

var x = {};
x.environment = current.variables.environment;
gs.addInfoMessage('x environment = ' + x.environment);

Sohithanjan G
Kilo Sage
Kilo Sage

Hi @rvranjan_99 

 

If current.variables.environment is indeed an object, you can use JSON.stringify to convert it into a JSON string, making it easier to log and inspect:

 

var x = {
    "environment": JSON.stringify(current.variables.environment)
};


OR
 var x={};
x.environment = current.variables.environment;

 

 

Please mark it as an accepted solution & HIT helpful if it suffices your requirement.


Thanks, Sohith

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)