ACL script to allow read access

chatsaurav19
Tera Contributor

Hi All,

 

What should be the correct script format for the highlighted one? I am trying to map the sys_id and then allow access for the user to see the records

 

var answer = false;
var recPrdcr = gs.getProperty('u_case.recordproducer.name'); //Property returning sys_id of the Catalog Item

if (gs.getUser().hasRole('case_reader_gbslogissue') && current.u_catalog_item == 'recPrdcr') {
answer = true;
}

 

Regards,

Saurabh Chatterjee

 

 

 

1 ACCEPTED SOLUTION

Sagar Pagar
Tera Patron

Hi @chatsaurav19,

 

The variable object should be without quotes.

 

Try this updated scripts:

var answer = false;
var recPrdcr = gs.getProperty('u_case.recordproducer.name'); //Property returning sys_id of the Catalog Item

if (gs.getUser().hasRole('case_reader_gbslogissue') && current.u_catalog_item == recPrdcr) {
	answer = true;
}

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

View solution in original post

4 REPLIES 4

Prince Arora
Tera Sage

@chatsaurav19 

 

For applying the second filter, I believe you are checking the catalog item, you can use the filter condition available on the ACL form and rest looks good.

PrinceArora_0-1691475973480.png

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

Hi @Prince ,

 

Actually I cannot use a filter condition since this ACL is used by many other applications plus this would become mandatory condition for the ACL to execute.

 

Regards,

Saurabh

Sagar Pagar
Tera Patron

Hi @chatsaurav19,

 

The variable object should be without quotes.

 

Try this updated scripts:

var answer = false;
var recPrdcr = gs.getProperty('u_case.recordproducer.name'); //Property returning sys_id of the Catalog Item

if (gs.getUser().hasRole('case_reader_gbslogissue') && current.u_catalog_item == recPrdcr) {
	answer = true;
}

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.
Thanks,
Sagar Pagar

The world works with ServiceNow

Aman Kumar S
Kilo Patron

Hi @chatsaurav19 

 

Update script as:

 

var answer = false;
var recPrdcr = gs.getProperty('u_case.recordproducer.name'); //Property returning sys_id of the Catalog Item

if (gs.getUser().hasRole('case_reader_gbslogissue') && current.getValue("u_catalog_item") === recPrdcr) {
       answer = true;
}

 

Best Regards
Aman Kumar