How to update the work notes time with todays time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 05:39 AM
Hi All,
I have written a fix script to update the state and work note of catalog task but it is updating the work notes with the older time not with todays time.
Could you please help me to update it with todays time.
var TSK = new GlideRecord('sc_task');
TSK.addEncodedQuery("active=true^sys_created_on<javascript:gs.beginningOfLast6Months()^stateNOT IN3,4");
TSK.query();
while (TSK.next()) {
TSK.setWorkflow(false);
TSK.Active = false;
TSK.state = 4;
TSK.work_notes = "This task has been automatically closed due to exceeding SLA by 6 months.";
TSK.update();
}
Regards,
Dp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2022 01:34 AM
Hi,
work notes data is stored in sys_journal_field table
So in order to modify the timings you need to change the sys_created_on field with your value for your record
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
04-05-2022 01:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2022 02:03 AM
Hi,
yes that's possible
query sys_journal_field table with your sc task sysId and work_notes and update the sys_created_on field using autoSysFields() function of gliderecord object
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader