Unable to query on sys_audit table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 07:52 AM
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 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 08:00 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 08:29 AM
Hi Ankur,
Yes, that's what I did. Why do you ask this ? Do you see anything strange ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2022 10:22 AM
Hello,
have you tried to use metrics to achieve this requirement ? it is much easier to do so i think
Ahmed
Please mark my answer as ✅ Correct / Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 01:07 AM
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 😞