- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 11:15 PM
Hi Everyone ,
I am trying to close some old cases through a Fix script without triggering Notifications to Opened for, Subject Person and Approvers with the below script.
var hrc = new GlideRecord('sn_hr_core_case');
hrc.addQuery('number', 'HRC0044626');
hrc.query();
while (hrc.next()) {
hrc.setWorkflow(false);
hrc.autoSysFields(false);
hrc.work_notes = "Closed through Fix Script";
hrc.state = '7';
hrc.active = false;
hrc.update();
}
But I cant update the work notes field.
when I use hrc.work_notes = " ", its not being updated unless something is posted in the worknotes manually.
setValue() and setJournalEntry() is not working.
Please pour your Suggestions.
Thank You!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 11:50 PM - edited 06-23-2025 11:51 PM
Hi,
This is due to the "setWorkFlow(false)" statement.
It prohibits the worknotes creation to be shown on the case, even though the record exists.
You can work your way around it by doing the update in two steps (see attached example).
Also, be aware that you could possibly get more than one record by query on the number.
If you want exactly one record, you should use the sysID as qualifier instead.
Also, I would recommend using the setValue method of GlideRecord whenever possible.
var hrc = new GlideRecord('sn_hr_core_case');
hrc.addQuery('number', 'HRC0044626');
hrc.query();
while (hrc.next()) {
hrc.setWorkflow(false);
hrc.autoSysFields(false);
hrc.state = '7';
hrc.active = false;
hrc.update();
hrc.setWorkflow(true);
hrc.work_notes = "Closed through Fix Script 2 parts solution.";
hrc.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 12:16 AM
Hi @OlaN, Thank you for youe Reply.Updating the worknotes with setWorkflow(false) does not trigger any Notifs for opened for/subject person ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 12:40 AM
Correct.
No notifications will be sent with setWorkFlow(false).
So in my suggested solution, the only notification(s) that would go out, is if you have a notification connected to a work-note creation (to case handler for example).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 11:51 PM
your script is correct and should update work notes, state and active field
Did you check any data policy is blocking the update since you are closing the HR case but may be some mandatory fields are not populated?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader