I want to create a ACL, with some condition

Community Alums
Not applicable

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

4 REPLIES 4

Mark Roethof
Tera Patron
Tera Patron

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

LinkedIn

Community Alums
Not applicable

Actually, it is working perfectly ,but to make it generic I wanted to define the condition under the script.

Thanks in Advance
Utsav

Satishkumar B
Giga Sage
Giga Sage

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.

Chenab Khanna
Tera Expert

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