Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

System property in ACL is not working

Bindhu1
Tera Contributor

Hi All,

I have created Create ACL  to give access to the 'New' button on the Related List for Catalog Tasks on the RITM form for specific group and catalog items.

Code works well when i give sys id of the catalog item directly but when i am storing the same sys id in system property and using in ACL script that time 'NEW' button wont be visible.
Here the code , Kindly help me how to achieve it from system property

 

//answer= (gs.getUser().isMemberOf('Administrative Business Center-Agents') && 
parent.cat_item=='7d2ded94db1b77002ed03df3399619e7');
// above line of code alone works good 

var customSysId = gs.getProperty('testCat_item_sysid'); // Retrieve the 'sys_id' from the system property

gs.info("bindu AA " + customSysId); // log gives proper sys id
gs.info("bindu BB " + gs.getProperty('testCat_item_sysid'));

answer = (gs.getUser().isMemberOf('Administrative Business Center-Agents') && parent.cat_item == customSysId);
        

 

 

Expecting result;

Bindhu1_0-1695377365125.png

 

Thanks in advance

 

1 ACCEPTED SOLUTION

@Bindhu1 

answer = (gs.getUser().isMemberOf('Administrative Business Center-Agents') && parent.cat_item.getValue('sys_id').indexOf(customSysId) > -1);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

17 REPLIES 17

@Bindhu1 

did you check any space is there in your property value?

try to use trim()

var customSysId = gs.getProperty('testCat_item_sysid'); // Retrieve the 'sys_id' from the system property

gs.info("brunda AA " + customSysId); // log gives proper sys id
gs.info("brunda BB " + gs.getProperty('testCat_item_sysid'));

answer = (gs.getUser().isMemberOf('Administrative Business Center-Agents') && parent.cat_item.sys_id == customSysId.trim());

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

I checked, No space is there in property value

Bindhu1_1-1695380950975.png

 

@Bindhu1 

are you sure the logged in user is member of that group?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Yes @Ankur Bawiskar because the script works fine for the same user when i keep sys_id of cat item directly .

answer= (gs.getUser().isMemberOf('Administrative Business Center-Agents') && parent.cat_item=='7d2ded94db1b77002ed03df3399619e7');

@Bindhu1 

strange

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader