How to request sys_audit_delete table ?

thibautdeflandr
ServiceNow Employee
ServiceNow Employee

Hi guys,

I would like to make a query on sys_audit_delete table but apparently it's not possible, indeed i always got a isValidRecord == false.

my code:

var myRecord = new GlideRecord('sys_audit_delete');

myRecord.addQuery('tablename', 'incident');

myRecord.addQuery('documentkey', 'myexistingdocumentkey');

myRecord.query();

gs.addInfoMessage(myRecord.isValidRecord()); //false

Also i can't access to this table through the rest API explorer.

Do you know why ? and if there is a possibility to access to the record (only read) of this table in a script include ?

Thanks a lot.

1 ACCEPTED SOLUTION

vinothkumar
Tera Guru

Hi Thibaut,



Try something similar as below and it worked. just changed the table name and document key and it is returning true. Can you check it



var myRecord = new GlideRecord('sys_audit_delete');  


myRecord.addQuery('tablename', 'u_vp_task_relationship');  


myRecord.addQuery('documentkey', 'a2ba47bbdb304700566cfe18bf96193e');  


myRecord.query();


if(myRecord.next())


{


gs.addInfoMessage(myRecord.isValidRecord()); //false


}


View solution in original post

5 REPLIES 5

adilrathore
ServiceNow Employee
ServiceNow Employee

Are you able to view the contents of this table as I believe you need to be a workflow_admin to view the contents.


I'm already able to see the data when i go in 'show list' in the table page.


Even with this role, i can't see the table in the rest api explorer.


Hello Thibaut,



Try with the below-updated code.



var myRecord = new GlideRecord('sys_audit_delete');  


myRecord.addQuery('tablename', 'sys_app_module');  


myRecord.addQuery('documentkey', '2cd790784f700300f3823879b110c77e');  


myRecord.query();  


myRecord.next();  


gs.addInfoMessage(myRecord.isValidRecord()); //false


vinothkumar
Tera Guru

Hi Thibaut,



Try something similar as below and it worked. just changed the table name and document key and it is returning true. Can you check it



var myRecord = new GlideRecord('sys_audit_delete');  


myRecord.addQuery('tablename', 'u_vp_task_relationship');  


myRecord.addQuery('documentkey', 'a2ba47bbdb304700566cfe18bf96193e');  


myRecord.query();


if(myRecord.next())


{


gs.addInfoMessage(myRecord.isValidRecord()); //false


}