adds the additional comment twice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 08:04 PM
Hi, I have written a server script in a ServiceNow widget. When this code executes, it adds the additional comment twice. I want it to create the comment only once
here is my code
if (input.app) {
// gs.addErrorMessage("my comments "+input.app);
// gs.addInfoMessage("my my approval record "+input.Record_sys_id);
var approvalSysId = input.Record_sys_id;
var grApproval = new GlideRecord('sysapproval_approver');
if (grApproval.get(approvalSysId)) {
grApproval.state='rollback';
grApproval.update();
var taskSysId = grApproval.sysapproval;
if (taskSysId) {
var table_name=taskSysId.getRefRecord().getTableName();
var grBR = new GlideRecord('sys_journal_field')
grBR.setWorkflow(false);
grBR.query();
grBR.initialize();
grBR.name =table_name ;
grBR.element = 'comments';
grBR.element_id =taskSysId;
grBR.value = input.app;
grBR.insert();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 08:47 PM
Hi @Community Alums
Is there a specific reason to add comments by inserting them into the sys_journal_field table instead of updating the comments directly in the task table using the taskSysId?
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 08:52 PM
this also adding comment twice
if (input.app) {
// gs.addErrorMessage("server script"+input.app);
// gs.addInfoMessage("testing everything"+input.app+" --"+input.Record_sys_id);
var approvalSysId = input.Record_sys_id;
var grApproval = new GlideRecord('sysapproval_approver');
if (grApproval.get(approvalSysId)) {
grApproval.state='rollback';
grApproval.update();
var taskSysId = grApproval.sysapproval;
if (taskSysId) {
var taskGR = new GlideRecord(taskSysId.getRefRecord().getTableName());
if (taskGR.get(taskSysId)) {
taskGR.comments = input.app;
taskGR.setWorkflow(false);
taskGR.update();
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 09:19 PM
@Community Alums
what's your actual business requirement? please explain that with screenshots.
If my response helped please mark it correct and close the thread so that it benefits future readers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2025 11:16 PM
Hi @Ankur Bawiskar , i have created widget and which have the approve reject and "more info required" button when i click on the more info required button i show one popup window to enter the additional comment. and when i submit that additional comment should reflects on that record's additional comment