Figure out table in which Field changes date and time recorded

Nandhinisri
Tera Contributor

Hi,

Whenever a state in problem is changed, the date and time in which it was changed is shown in activities tab. But I want to know in which table it is stored in order to execute that in a script. I am attaching the ss for reference. Any suggestion would help.

 

Nandhinisri_0-1735626571232.png

 

TIA

8 REPLIES 8

@Nandhinisri 

you can use getDisplayValue() to get the value in user timezone

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Nandhinisri 

if the table is audited then it gets stored in Audit (sys_audit) table

The data in activities filter is brought and rendered from there.

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 

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