How to update variables using a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-06-2015 01:28 PM
Hi ServiceNow Community Developers,
Is there a way to update a variable on the sc_req_item using something like a batch script. I do this all the time with the incident table going after fields but it looks like its different when you are going after variables. For instance I have the following batch script
gs.log("running it");
var items = new GlideRecord('sc_req_item');
items.addQuery('number', 'RITM0011306');
items.query();
while (items.next()) {
gs.log ("data found " + items.cat_item.name);
gs.log ("data found " + items.variables.asset_name);
items.variables.asset_name = 'No Asset';
items.update();
}
Now asset_name is a variable and thats why my script does not work, if asset_name was a field on this table I am pretty sure it will work. Both my gs.log statements work fine, they give me the data I want, it's the update part that is not working and I think its because maybe I need to code it differently since I am dealing with a variable.
Would you please advise as to what do I need to do in order to get the desired functionality here.
Thanks,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2015 05:53 AM
Hi Guys,
Thanks to all of your for your responses. So far I have tried all the suggestions but still without any luck.
What I have decided to though is to correct the RITMs manually. There are 54 tickets in production that are messed up so I will just take them one by one and fix them all.
Once again, I greatly appreciate your suggestions in trying to resolve this issue.
Johannes