I want to create a ACL, with some condition

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2024 09:20 PM
I wanted to create a new ACL, with condition as "Assignment group is IT" but I wanted to write this condition in the script. Please help me with this...
Thanks in Advance
Utsav

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2024 09:23 PM
Hi there,
Can you share what you tried and where you are stuck exactly?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2024 09:35 PM
Actually, it is working perfectly ,but to make it generic I wanted to define the condition under the script.
Thanks in Advance
Utsav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2024 09:50 PM
Hi @Community Alums
check below script if your expecting this:
(function() {
// Define the target group name
var targetGroupName = 'IT';
var gr = new GlideRecord('your_table_name');
gr.addQuery('name', targetGroupName);
gr.query();
if (gr.next()) {
var targetGroupId = gr.getUniqueValue();
// Return true if the assignment group matches the target group ID
return current.assignment_group == targetGroupId;
}
// Return false if the group is not found
return false;
})();
…………………………………………..
Mark it helpful 👍and Accept Solution ✅!! If this helps you to understand.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2024 02:03 AM
Hi @Community Alums
If you want to write this condition in ACL script and make it generic, create a system property and add your assignment group value there, then call the property in the script as below -
if(current.assignment_group == gs.getProperty('property_name')){
answer = true;
}
else{
answer = false'
}
This way, if there is any change in the group, you don't have to modify your acl in any way. Just change the value in the system property