Validation based on Assignment group type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2024 07:08 PM - edited ‎06-01-2024 09:10 PM
In the incident form i want to make sure that the field Assignment group can be modified only if the logged in users assignment group type contains ITSM. How can we achive this by using ACL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2024 11:39 PM
Hi @JPSS ,
Please find the ACL script for your reference:
var userId = gs.getUserID();
var hasITSM = false;
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.query();
while (gr.next()) {
var groupId = gr.group.sys_id;
var groupGr = new GlideRecord('sys_user_group');
if (groupGr.get(groupId) && groupGr.u_group_type.indexOf('ITSM') > -1) {
hasITSM = true;
break;
}
}
answer = hasITSM;
If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.
Thanks,
Amitoj Wadhera

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2024 12:08 AM
Since the ACL runs on multiple records, we need to be very mindful of the number of GlideRecord queries we are making from the ACL.
You need to define a field level write ACL on the assignment group field with following script.
var glideMember = new GlideRecord('sys_user_grmember');
glideMember.addEncodedQuery('group.nameLIKEITSM^userDYNAMIC90d1921e5f510100a9ad2572f2b477fe');//Uses a dynamic filter for logged in user it is same across all the instances
glideMember.query();
var isITSMMember = false;
if(glideMember.hasNext()){
isITSMMember = true;
}
answer = isITSMMember;
This script uses a single glide record query with a filter for group name which contains ITSM and a dynamic filter for the logged in user.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2024 06:47 AM
Hi @JPSS,
1) Create table-level WRITE ACL
2) Advanced script checkbox true
3) Script
var usr = gs.getUserID();
var user = new GlideRecord("sys_user_grmember");
user .addEncodedQuery('group.typeLIKE1cb8ab9bff500200158bffffffffff62'); //replace this sys_id with the type you want to look for
user .addQuery('user', usr);
user .query();
var itilmember = false;
if (user .next()) {
itilmember = true;
}
answer = itilmember ;
}
Please mark this response as correct or helpful if it assisted you with your question.