How to populate Catalog item based on user login?

suresh40
Tera Contributor

Hi All,

 

I have requirement, to populate  catalog item based on user login using back ground script.

 

Example: If Able Turte login to the portal he has only some catalog item has access to visible That item has visible using background script .Please help me on this .

 

Thanks 

Suresh 

13 REPLIES 13

Prince Arora
Tera Sage
Tera Sage

@suresh40 ,

 

You can define "user criteria" for those catalog items, it is an OOB functionality provided by ServiceNow to show/hide catalog items based on roles and conditions.

 

Please find this link for more info on user criteria, you can also mention conditional scripts in the User Criteria.

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Hi  Prince,

 

In user criteria we have only 30 user criteria. If we not created user criteria for all catalog item . That's item has to visible  for based on login user using background script.    

 

Thanks,

Suresh

 

Ankur Bawiskar
Tera Patron
Tera Patron

@suresh40 

You can use UserCriteriaLoader API for this.

Example below:

1. getAllUserCriteria - Returns an array of all user criteria's matched by the logged in user
var allCriterias = new sn_uc.UserCriteriaLoader.getAllUserCriteria(gs.getUserID());
gs.info(allCriterias);
gs.info(allCriterias.length);

Reference:

UserCriteriaLoader - API to Evaluate User Criteria 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

In user criteria we have only 30 user criteria. If we not created user criteria for all catalog item . That's item has to visible  for based on login user using background script.    

Thanks 

Suresh