- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 03:09 AM - edited 09-25-2023 01:04 AM
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;
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 04:03 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 01:15 AM
@Ankur Bawiskar @Vishal Birajdar
Hi, thanks for your help.
ACL script works fine when i use includes() method like below
answer = (gs.getUser().isMemberOf('Administrative Business Center-Agents') && customSysId.includes(parent.cat_item.getValue('sys_id')));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 01:49 AM
not sure it should have worked earlier as well as that script looks good to me
you can use indexOf() then
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 03:51 AM
Hi @Ankur Bawiskar
Could you please give me an example how indexOf() works here.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 04:03 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2023 03:34 AM
Hi @Bindhu1
Can you try using if-else.
var customSysId = gs.getProperty('testCat_item_sysid'); // Retrieve the 'sys_id' from the system property
var isMember = gs.getUser().isMemberOf('Administrative Business Center-Agents');
if ( isMember && (parent.cat_item == customSysId) ) {
answer = true;
} else {
answer = false;
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates