- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 12:06 PM
wrote a script under "sysauto_script.list" to update "Configuration Item" of closed incidents.
Trying to test it for one incident before running a update for all.
var gr = new GlideRecord('task');
gr.addQuery('number','INC2142115');
gr.query();
while(gr.next()){
gr.cmdb_ci = 'Atlas';
gr.update();
}
the following error is seen in work notes of the ticket.
Can someone please help to find the reason for the update not going through.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 12:19 PM
You should use sys_id or displayValue.
var gr = new GlideRecord('task'); // why are you referring to task table here instead of incident
gr.addQuery('number','INC2142115');
gr.query();
while(gr.next()){
gr.setDisplayValue('cmdb_ci', 'Atlas');
gr.setWorkflow(false);
gr.update();
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 12:08 PM
Try this:
var gr = new GlideRecord('task'); // why are you referring to task table here instead of incident
gr.addQuery('number','INC2142115');
gr.query();
while(gr.next()){
gr.cmdb_ci = 'Atlas';
gr.setWorkflow(false);
gr.update();
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 12:15 PM
Thank you for your quick reply Prateek.
Same problem with incident and setWorkflow function.
I've tried on a different incident, the field just goes to empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 12:19 PM
You should use sys_id or displayValue.
var gr = new GlideRecord('task'); // why are you referring to task table here instead of incident
gr.addQuery('number','INC2142115');
gr.query();
while(gr.next()){
gr.setDisplayValue('cmdb_ci', 'Atlas');
gr.setWorkflow(false);
gr.update();
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-15-2019 12:25 PM
Would you mind closing the thread by marking my response as correct.
This helps in removing the thread from unanswered list and helps community.
-Cheers
Prateek
Please mark my response as correct and helpful if it helped solved your question.
-Thanks