Understanding Audit History and how it works

scottangehr
Giga Guru

I've recently enabled the audit history on a table and have been pulling reports.   What I'm not understanding is that I have multiple records that are not showing in an appropriate time frame.   For example, an incident was closed on 4/15/15 but the audit for the state field did not show up until 5/2/15 which seems to have been provoked by querying the specific record.

IDLabelOldNewTypeUpdate numberUpdate time
POI21623StateOpenWork in ProgressAudit34/27/2015 9:41
POI21623StateWork in ProgressPendingAudit44/27/2015 10:28

The state was changed to Closed on 2015-04-27 10:36:03 and I just pulled this data.


How long does the complete audit history of a record take to show in the audit history?

1 ACCEPTED SOLUTION

Scott,



Yes, the "Audit History" and "Audit Records" are both generated on demand by pulling data from sys_audit.  



If you want to report on the "Audit History" table (since it is more end user friendly), you could create a scheduled job to force the "Audit History" and "Audit Records" tables to update for the records you are interested in, and then run a scheduled report to report on the data in the "Audit History" table.  



Please make sure you have some limit for the number of records being updated in the Audit tables!   Generating the Audit data for all incidents could potentially cause performance issues.



A scheduled job similar to this would populate the Audit tables for all incidents updated this quarter:


var gr = new GlideRecord("incident");


gr.addQuery("sys_updated_on", ">", gs.beginningOfThisQuarter() );


gr.query();


while( gr.next() ){


  new GlideHistorySet("incident", gr.sys_id).generate();


}



Thanks


Brian


View solution in original post

5 REPLIES 5

Hi Brian - this is very useful info, thanks! 

 

Is it possible to get the same data directly from 'sys_audit' without generating records in 'Audit History'? I tried but seems not working so not sure what i am missing here.

 

Thanks in advance!