new SNCCatalogUtil().canRead(current.sc_cat_item,current.isNewRecord());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 01:45 AM
Hi Team
Can anyone please help on what this below code is doing, it is not letting some of our user to see catalog item relationship data. It is being used in the script condition of an ACL.
new SNCCatalogUtil().canRead(current.sc_cat_item,current.isNewRecord());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 02:30 AM
Hi @kapil_shinde,
When you see syntax such as "new SNCCatalogUtil().canRead(current.sc_cat_item,current.isNewRecord());" - it's important to understand what's going on here.
"new" instantiates a Script Include "SNCCatalogUtil". If you search the Script Includes module, you see there is one called: SNCCatalogUtil
Within the Script Include, you'll see a method called canRead. This is being called as signified by the full stop (.)
new SNCCatalogUtil().canRead(current.sc_cat_item,current.isNewRecord()).
Again viewing the Script Include (As shown below, the canRead method accepts 2 parameters - the cat item, and whether the record is a isNewRecord.
This method then calls the .canWrite method within the same Script Include and will either return true (or false)
Here's a link to the ServiceNow docs and Scripting and instantiating:
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie