ACL fields from other table

priyanka68
Tera Contributor

Hi ,

 

i have to write an ACL if state is closed complete on the incident form then in the related list one table should be editable only for admins.

 

i have given the table name and added roles. Can someone help with the script.

var user = gs.UserID();
var gr = new GlideRecord('incident');
gr.addQuery();
while (gr.next()) {
var state = incident_state;
if ((state == 'closed complete') ) {
answer == true;
}
else{
answer == false;
}
}

Thanks

1 REPLY 1

Tony Chatfield1
Kilo Patron

Hi, your ACL needs to be on the target table (the related list) not on your Incident table, your query will need to check the related incident to see if your conditions are met.

 

You haven't provided clear details of your record relationships and closed complete is not an OOB incident state, so difficult to understand your intentions, but it sounds like you want a list edit ACL, for the itil role, with admin override = true
Then you just need to check the value you want\don't want to allow, also task 'state' values are normally an integer ie incident closed = 7

This is untested and only a guide as exact details are missing.

 

answer = false;

var gr = new GlideRecord('incident');
// query your relationship I have guessed its called 'parent' but maybe not?
gr.addQuery('sys_id', current.parent.toString());
gr.query();

if(gr.next()) {
//if the incident state is not closed allow your users to edit
if(gr.incident_state != 7) {
answer == true;
}
}

 

 

Edit: if there is only one query and it is always valid (field will always be populated, then you can also use 'get' to simplify query syntax
GlideRecord | ServiceNow Developers

 

answer = false;

var gr = new GlideRecord('incident');
// query your relationship I have guessed its called 'parent' but maybe not?
gr.get(current.parent.toString());

//if the incident state is not closed allow edit
if(gr.incident_state != 7) {
answer == true;
}