Update or replace existing comments or work notes in Incident Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 02:49 AM
function commentsDialog() {
gsftSubmit(null, g_form.getFormElement(), 'comments_dialog');
}
var gr = new GlideRecord("incident");
gr.addQuery('number', current.number);
gr.addQuery("element", "comments");
gr.query();
if (gr.next()) {
var notes = gr.comments.getJournalEntry(-1);
//gets all journal entries as a string where each entry is delimited by '\n\n'
var na = notes.split("\n\n");
//stores each entry into an array of strings
for (var i = 0; i < na.length; i++) {
var data = na[i];
gs.addInfoMessage(data);
gr.comments = "testing " + i;
gr.update();
}
}
action.setRedirectURL(gr);
How to replace or update all existing comments/work notes in an Incident.
Here we are able to get all comments but we want to update it by adding some text to it instead of adding a new one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 04:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 07:35 AM
Hi,
the above script is not complete one
please share the complete script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 10:52 PM
thats the complete script in the UI Action. i don't know what script are you looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-09-2022 10:58 PM
Hi,
make your UI action as server side and use this code
Uncheck Client checkbox on UI action
Clear the Onclick field on UI action
var gr = new GlideRecord("sys_journal_field");
gr.addQuery('name', 'incident');
gr.addQuery("element", "comments");
gr.query();
while (gr.next()) {
gr.value = "testing - " + gr.value;
gr.update();
}
action.setRedirectURL(gr);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2022 12:13 AM