sp.canReadRecord method

raed1
Giga Contributor

Hey guys,

I am trying to figure out a bug in my code. Can someone tell me what property does the canReadRecord method check against, on a catalog item to return a true or a false value? I have checked roles, available for, not available for on the catalog item, but they don't seem to have any effect on the outcome. Thank you.

1 ACCEPTED SOLUTION

raed1
Giga Contributor

Fixed! It was an sc_cat_item read ACL. I had to add the role there

View solution in original post

3 REPLIES 3

Mike Patel
Tera Sage

Can you share code?

raed1
Giga Contributor

Hey Mike, this is the code. I have bolded the if statement with the canReadRecord

 

while (catalog_items.next()) {
   if (!$sp.canReadRecord("sc_cat_item", catalog_items.sys_id.getDisplayValue()))
      continue; // user does not have permission to see this item

   var item = {};
   item.name = catalog_items.name.getDisplayValue();
   item.short_description = catalog_items.short_description.getDisplayValue();
   item.picture = catalog_items.picture.getDisplayValue();

   //Item Price handling for dollar currency, so that the $0.00 check in the HTML can evaluate to true if prize is 0
   item.price = catalog_items.price.getDisplayValue();
   item.price = item.price.substring(item.price.indexOf('$'));

   item.sys_id = catalog_items.sys_id.getDisplayValue();
   items.push(item);
}

raed1
Giga Contributor

Fixed! It was an sc_cat_item read ACL. I had to add the role there