- 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-23-2025 11:23 PM - edited 06-23-2025 11:25 PM
Hi @Madhan007 ,
delete the sys_history_set records of the record
the work notes will reflect
refer responses in below thread
https://www.servicenow.com/community/csm-forum/close-case-script-add-work-notes/m-p/3276191
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 12:21 AM
Hi @Madhan007
If you check the journal entry table the work note entry would be there
It's just that it's won't show up the form with setworkflow false sometimes
Delete the history set records for the records
The work notes will show up
Regards
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 11:34 PM
Hello @Madhan007 , @
I actually faced the same issue before. The problem is likely due to the setWorkflow(false)
and autoSysFields(false)
lines in your script. Since work_notes
is a journal field, these settings can prevent it from being updated properly.
Try removing both lines and run the script again — it should update the work notes as expected.
Hope that helps!
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Regards,
Aniket

- 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();
}