How to access catalog item attributes from user criteria script

acirovic1
Giga Expert

Within entitlement scripts it was possible to access the catalog item using current object and calling current.getID() to retrieve the catalog item sys_id.

With user criteria script, this is no longer possible as there is no access to the current object. Does somebody know how to access the catalog item attributes from within a user criteria script.

Regards,

Alex

11 REPLIES 11

I meant "... for which catalog item.."


You can create a script include which will query on "sc_cat_item_user_criteria_mtom" table and will return the user criteria which are applicable. You can call this script include from any server side script, including user criteria script.


What goal you are trying to achieve?


But that's not what I want, I need to read a value in one field of the current catalog item for which the user criteria is being evaluated for.


garrett_griffin
Tera Contributor

Hey Aleksandar,



I had the same need today, so I spent a lot of time investigating.



You *CAN* get the current catalog item's sys_id via: RP.getParameterValue("sysparm_id") -- at least you can in some situations.




HOWEVER, the system cache's this result. It runs each user criteria once for a user, but it will not run the User Criteria script a second time during that user session.



This means that if I open "Catalog Item ABC" -- it will run the script, using that catalog item's sys_id.



Then if I open "Catalog Item XYZ", it does NOT run the script, but just uses the cached result from the last time.



In the end what you and I are forced to deal with, is that we cannot utilize or rely on any attributes of a particular Catalog Item in our user criteria. Instead we need to flip the problem on it's head, and figure out how to make the User Criteria record agnostic.


I was suspecting this. Have you investigated if it's possible to have both, user criteria and entitlement script, evaluated at the same time (or in sequence)?