- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 05:44 AM
Hi,
I was wondering about (pointlessly?) doing a belt and braces check before deleting a record. From what little I know of table, row & field ACLs, I believe the best place to do a canDelete() check would be inside my record loop as in:
var gr = GlideRecord('sc_req_item');
gr.addQuery('cat_item', sid);
gr.query();
while (gr.next()){
if (gr.canDelete()) {
// do delete
} else {
// log fail
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 05:57 AM
Hi Matt,
canDelete() evaluates ACL and it should be table level I believe i.e. record level as you will be deleting record
I believe you can use canWrite() at field level and also canRead(); canCreate(), canDelete() won't work at field level
example: current.state.canWrite()
https://hi.service-now.com/kb_view.do?sysparm_article=KB0677278
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
04-28-2020 05:50 AM
Hey,
Instead of sid, write sys_id.
Thanks
Tanushree

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 05:56 AM
Hi Matt,
You can do the check outside the while loop(At Table level) and then continue with next steps I.e
var gr = GlideRecord('sc_req_item');
var Del = gr.canDelete();
if(Del == true)
{
//
}
- Pradeep Sharma
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 05:57 AM
Hi Matt,
canDelete() evaluates ACL and it should be table level I believe i.e. record level as you will be deleting record
I believe you can use canWrite() at field level and also canRead(); canCreate(), canDelete() won't work at field level
example: current.state.canWrite()
https://hi.service-now.com/kb_view.do?sysparm_article=KB0677278
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader