Issue with User Criteria Script

CCZMAX1
Mega Sage

Hi I am trying to write a user criteria script to restrict users from accessing standard change templates where they are not a member of the assignment group listed in the template.  It works in background scripts but when I apply it to a record and impersonate a user no standard change templates display even though they are a member of the group listed in the template.  I have logged in and out several times.  Here is my script.  Any help appreciated as I am still pretty new to scripting. Thanks

 

var answer = false;
var assignmentGroup;

var user = new GlideUser.getUserByID(user_id);
 
var template = new GlideRecord('std_change_record_producer');
template.addQuery('active', true);
template.addNotNullQuery('u_assignment_group');
template.query();

while (template.next())
{
    assignmentGroup = template.u_assignment_group;
    answer = user.isMemberOf(assignmentGroup);
}
1 ACCEPTED SOLUTION

Ramz
Mega Sage

Hi @CCZMAX1 ,

Please use Read ACL  on the table for this requirement.

Use scripts in ACL to achieve this

Please mark my answer correct/helpful if it resolved your query

 

View solution in original post

4 REPLIES 4

Papai Ghosh
Tera Contributor

Hi ,

If I am not wrong, you want to restrict the logged in user to apply the change template when creating a new record, then I think you can restrict the change template visibility, as for them the change template will not be show they cannot create new change based on these templates. 

Thanks for the reply.  Yes, I want to restrict the logged in user from apply the change template and also I don't want them to be able to see it to attempt to apply.  Was hoping I could achieve this via a user criteria but my script it not working. 

 

Hi,
Please use Read ACL on the Template table for this requirement. For more flexibility you can add script in the ACL. 

 

Thanks, 

Papai

Ramz
Mega Sage

Hi @CCZMAX1 ,

Please use Read ACL  on the table for this requirement.

Use scripts in ACL to achieve this

Please mark my answer correct/helpful if it resolved your query