
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2017 07:10 AM
Dear All,
I am trying to modify a variable *Reason for order* of an existing RITM record through background script , but unable to access the variable (script throws an error).
Below is the code snippet :
var obj = new GlideRecord('sc_req_item');
obj.addQuery('sys_id','dc60c6eddb14430020a656f0cf961988');
obj.query();
gs.log("Record number is :"+obj.getRowCount()); //got the Row Count as 1
if(obj.next())
{
obj.reason = 'New Phone Request';
obj.update(); //trying to update the variable of RITM record
}
However, whenever I am running this script, variable *Reason for Order* remains the same as its previous value --> damaged device received.
Please let me any appropriate script modification.
Best Regards,
Puru
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2017 07:14 AM
Hi Pururava,
you can write something like
obj.variables.variable_name;
so your script should be like
var obj = new GlideRecord('sc_req_item');
obj.addQuery('sys_id','dc60c6eddb14430020a656f0cf961988');
obj.query();
gs.log("Record number is :"+obj.getRowCount()); //got the Row Count as 1
if(obj.next())
{
obj.reason = 'New Phone Request';
obj.variables.variable_name = 'name';
obj.update(); //trying to update the variable of RITM record
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2017 07:14 AM
Hi Pururava,
you can write something like
obj.variables.variable_name;
so your script should be like
var obj = new GlideRecord('sc_req_item');
obj.addQuery('sys_id','dc60c6eddb14430020a656f0cf961988');
obj.query();
gs.log("Record number is :"+obj.getRowCount()); //got the Row Count as 1
if(obj.next())
{
obj.reason = 'New Phone Request';
obj.variables.variable_name = 'name';
obj.update(); //trying to update the variable of RITM record
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2017 07:17 AM
Variables are access through the variables object.
You need to set this like ths
obj.variables.reason = 'Your new reason';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2017 07:22 AM
Hi Puruva,
If the workflow is on the RITM table itself, you can simply use the line current.variables.variable_name = 'New Phone Request';; // if a variable
else current.variable_pool.variable_name = 'New Phone Request';; //if variable a part of variable set.