How to update the work notes time with todays time

Datta Pisal
Kilo Explorer

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.

image

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

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you For your reply!!

Actually i want to update the timing filed, Please check below highlighted part.

find_real_file.png

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader