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-04-2022 08:05 AM
Hello zazaza,
The usage of setWorkflow(false) statement prevents the addition of work notes, as well as suppresses the execution of business rules and notifications.
If you want to generate a new work note, you need to remove the setWorkflow(false) statement.
Please mark my answer as correct and helpful if it is relevant for you!
Thanks,
Filipe Cruz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 09:17 AM
Thank you for reply!!
But is there any syntax to update that field?
Regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 10:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2022 11:06 PM
Hi,
I want modify the above code so can using some syntax I can update work note field timing as well.
Regards,