new SNCCatalogUtil().canRead(current.sc_cat_item,current.isNewRecord());

kapil_shinde
Tera Expert

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());

1 REPLY 1

Robbie
Kilo Patron
Kilo Patron

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:

https://developer.servicenow.com/dev.do#!/learn/learning-plans/washingtondc/new_to_servicenow/app_st...

 

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

 

Screenshot 2024-06-25 at 10.26.42.png