- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 05:11 AM
Hi,
How can I insert a comment into additional comments on incident table using script, i tried with this script but I had no luck:
var gr = new GlideRecord('incident');
gr.addEncodedQuery('sys_id=422122f79dc1311020d2b7cbb48c1914');
gr.query();
if(gr.next()){
gr.comments.setJournalEntry('Please reopen this incident.');
gr.upadte();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 07:43 AM
You can try the following:
var comInc = new GlideRecord('incident');
comInc.get('422122f79dc1311020d2b7cbb48c1914');
comInc.query();
while(comInc.next()) {
comInc.comments = "Please reopen this incident.";
comInc.update();
}
The setJournalEntry is add additional attributes to the comment, you can find more info on it here: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0748347
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:40 AM
Hi @Alon Grod
Please try below -
var gr = new GlideRecord('incident');
gr.addEncodedQuery('sys_id=422122f79dc1311020d2b7cbb48c1914');
gr.query();
if (gr.next()) {
gr.work_notes = 'Please reopen this incident.'; // Use the work_notes field for additional comments
gr.update();
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 07:43 AM
You can try the following:
var comInc = new GlideRecord('incident');
comInc.get('422122f79dc1311020d2b7cbb48c1914');
comInc.query();
while(comInc.next()) {
comInc.comments = "Please reopen this incident.";
comInc.update();
}
The setJournalEntry is add additional attributes to the comment, you can find more info on it here: https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0748347
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 07:17 AM
Thx!
This syntax
comInc.comments = "Please reopen this incident.";
worked for me
instead of
comInc.setValue('comments','Please reopen this incident.');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 08:39 AM
Please find the Script below.
Script :