Adding comments on incident using Background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 05:14 AM
Hello,
Iam adding comments on incident using background scriprt:
var gr = new GlideRecord("incident");
gr.addEncodedQuery('numberININC0000002,INC0000003,');
gr.query();
while(gr.next())
{
gr.setValue('state', 1);
gr.comments='hello world';
gr.setWorkflow(false); // Bypass business rules and workflows
gr.update();
}
State is getting changed, but comments are not added in the incident activity.
How to add comments on incident using background script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 05:18 AM
Hi @Geetha9
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 05:25 AM
Hi ,
You can try below code,
var grInc = new GlideRecord('incident');
grInc.get('sys_id');
grInc.query();
while(grInc.next()) {
grInc.comments = "Comments which you want to set.";
grInc.update();
}
If my answer is helpful mark it as helpful or correct!
Br,
pratiksha.k
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2023 05:38 AM
Script which you have written looks good to me, there are no issues in it and it worked for me!