Unable to query on sys_audit table

mathieu_brule
Kilo Sage

Hi everyone !

I'm facing difficulties on querying sys_audit table by script.

Indeed, this request is taking lots and lots and lots of time for being executing : 

var grAudit = new GlideRecord("sys_audit");
grAudit.addEncodedQuery("tablename=problem_task^ORtablename=problem^fieldname=assigned_to^newvalue=5942b6cf1b23c994358eddf59b4bcb3d^sys_created_on>javascript:gs.endOfLastYear()");
grAudit.query();

 

The aim of this request is to know if an user has already been assigned to a problem or a problem_task record.

 

Do you know if I can do something for this request to work better ?

 

Thanks a lot for your help !

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

are you sure the query you mentioned is correct?

I would suggest to use filter conditions and form the query and from there you copy the query and use as encoded query

Regards
Ankur

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

Hi Ankur,

 

Yes, that's what I did. Why do you ask this ? Do you see anything strange ?

Ahmed Drar
Tera Guru
Tera Guru

Hello,

have you tried to use metrics to achieve this requirement ? it is much easier to do so i think

https://docs.servicenow.com/bundle/tokyo-platform-administration/page/use/reporting/task/create-metr...

I hope this helps.

Ahmed

Please mark my answer as Correct / Helpful based on the Impact.

Hi Ahmed,

Thanks for your feedback.

Yes I know metrics, but I need my resultats now (I'm doing a study on licences usages), and if I'm not wrong, metrics could not answer me quickly 😞