How to update variable value using background script

ak49
Tera Contributor

I have to update the variable value on ritm and task form using the background script. Could you please help me with that?

Variable backend name 'var_isInternational' and I need to set 'Yes or No' value using background script.

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

Hi @ak49 

You can use below script:

 

try
{
var gr=new GlideRecord("sc_req_item");
gr.get("GIVE SYS_ID HERE");
gr.variables.var_isInternational="GIVE VALUE HERE"; //updated this line
gr.setWorkflow(false); //to stop BR's
gr.update();
}
catch(e)
{
gs.info("Error: "+e.message());
}

 

Hope it helps

 

Thanks,
Murthy

View solution in original post

3 REPLIES 3

Murthy Ch
Giga Sage

Hi @ak49 

You can use below script:

 

try
{
var gr=new GlideRecord("sc_req_item");
gr.get("GIVE SYS_ID HERE");
gr.variables.var_isInternational="GIVE VALUE HERE"; //updated this line
gr.setWorkflow(false); //to stop BR's
gr.update();
}
catch(e)
{
gs.info("Error: "+e.message());
}

 

Hope it helps

 

Thanks,
Murthy

Can you please share the code where we can update different old values with multiple new values. Something like 

if RITM has 10 number should be updated with ABC or if RITM has 20 number it should be updated with XYZ values..

Mike_R
Kilo Patron
Kilo Patron

var ritm = new GlideRecord('sc_req_item');
ritm.get('sysIDofRITMyouWantToUpdate'); // Pass in the sys_id of the RITM
ritm.variables.var_isInternational = 'No'; // Or 'Yes' if you want to set to yes
ritm.update();