Capture Audit history with setworkflow(false)

Nik Amy
Tera Contributor

Hey Guys,

1.

In one of the data source, 'Run Business rules' is unchecked. Is it still possible to capture the changes/updates done in the audit history.

2. In another data source,   'Run Business rules' is checked, with we have used 'setworkflow(false)' which again does not capture the audit changes. But we need those audit details.

Is there a solution for this.

TIA

Nikh

5 REPLIES 5

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

The setWorkflow(false) will not do any audit:



GlideRecord - ServiceNow Wiki



You need to have it set to "true" if you want audit.


Yes, setWorkflow(false) was written with a purpose. So I am looking for a scenario where setWorkflow(false) is used and still changed are audited.



That can't be done with setWorflow then. One of the things to keep in mind here is that imports that run very often, if they do keep the audit, can increase the sys_audit to a very large size and then you might run into other performance issues. So, if you have such imports, I would think twice if I really need the audit data.


jagarnathn
Tera Expert

There is a way to do it.



You need to create a custom table   against the table you want audit.



For the table where you do not want audit make serWorkflow(false) and pass the the values to custom tables to get   it updated.



var gr= new GlideRecord('incident');


gr.get('sys_id');


gr.test="something to update";


gr.setWorkflow(false);


gr.update();



var gr1= new GlideRecord('u_incident');


gr1.intialize();


gr1.number=gr.number;


gr1.test=""something to update";


gr1.insert();



Thanks,


Jagarnath