Getting the exact time and date when the problem record is updated as Fix in progress

Nandhinisri
Tera Contributor

Hi

How can I fetch the exact time and date of when the state is updated as Fix in progress. We do have updated time which fetches date and time of update in sys_history_line table. But I am not sure how to implement the above said condition and take that particular value.

Nandhinisri_0-1735640255750.png

TIA

1 ACCEPTED SOLUTION

@Nandhinisri 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Nandhinisri 

it's stored in sys_history_line and sys_history_set

to get the exact time use this filter

Also the Update time it shows on form/list is as per logged in user's timezone

If you open that record and see the value it will always be in GMT

Label - State

Old - Root cause analysis

New - Fix in progress

Use the Update time

So the value you see in activity filter is as per logged in user's timezone

 

AnkurBawiskar_0-1735640722941.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Nandhinisri 

something like this in background script

var probRec = new GlideRecord('problem');
probRec.addQuery('sys_id','recordSysId'); // give correct sysId here
probRec.query();

if(probRec.next()){

    var history = new GlideRecord('sys_history_set');
    history.addQuery('id',probRec.getValue('sys_id'));
    history.query();
    history.next();

    var auditH = new GlideRecord('sys_history_line');
    auditH.addQuery('set',history.getValue('sys_id'));
    auditH.addEncodedQuery("field=state^newISFix in Progress^oldISRoot Cause Analysis"); 
    auditH.query();
    if(auditH.next()){
        gs.info('Update time is' + auditH.getValue('update_time'));
    }

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Nandhinisri 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Yes @Ankur Bawiskar  The code you have given me above does give me a clarity. Thanks! Happy learning.