why Glide Record query is not running for non admin users and how to fix this issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 07:49 PM
Hello Everyone,
I have a GlideRecord query in a widet to create SC_TASK record when user click on "Reopen" buttton.
as an admin when i click "reopen" , my code is working and sc task is creating
but when i ipersonate and test with an ITIL user , then the code is not working , i just printed the getRowCount() , i am getting 0 when i tested with ITIL user
below is my script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2024 10:00 PM
it means there is Query BR on sc_task is blocking the query
try this
var lastClosedTask = new GlideRecord('sc_task');
lastClosedTask.addQuery('request_item', sys_id);
gs.info("Sysid of RITM :" + sys_id);
gs.info("Sysid of RITM1 :" + gr.sys_id);
lastClosedTask.addQuery('state', 3);
lastClosedTask.orderByDesc('closed_at'); // Get the most recent closed task
lastClosedTask.setLimit(1);
lastClosedTask.setWorkflow(false);
lastClosedTask.query();
gs.info('No.of SC TASKS avaialble for RITM ' + gr.number + '--->' + lastClosedTask.getRowCount());
if (lastClosedTask.next()) {
gs.info("last closed SCTASK No : " + lastClosedTask.number);
var newTask = new GlideRecord('sc_task');
newTask.initialize();
newTask.request_item = sys_id;
newTask.assignment_group = lastClosedTask.assignment_group; // Assign the specified assignment group
newTask.short_description = "Ticket is reopened by " + gs.getUserDisplayName();
newTask.insert();
gs.info("NEW SCTASK Created : " + newTask.number);
} else {
gs.info("Im from line no.78");
gs.info("No SCTASK is present for RITM :" + gr.number);
}
/
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 09:46 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader