The CreatorCon Call for Content is officially open! Get started here.

How to limit the user list when checking out on the catalog?

gjz
Mega Sage

In my company, we have "super users" who are allowed to order items on behalf of other people in their department.  They don't have an ITIL role, they have a modified ITIL role that was created for them.

 

When a catalog item is ordered, on the Order Confirmation popup, the Request for field needs to be limited to the people in the department if the logged in user is one of the "super users", all other users will retain the OOB functionality.  What is the best way to do that?  Can it be done through a business rule or do I have to clone and modify the sc-checkout widget?  If it has to be in the widget, can someone point me to where the code will need to be modified?  I'm not good at modifying widgets.

 

I've done some searching and I find there is a system property "glide.sc.request_for.query" that seems to be used to determine who is in the list.  Can I put complex javascript in the property's value?  How does the widget know who the logged in user is?

 

 

 

gjz_0-1735687984894.png

 

9 REPLIES 9

rambo1
Tera Guru

HI @gjz 

you will need to modify catalog check out widget , below is OOTB link :

sp_config?id=widget_editor&sys_id=1efb954a7f900300688e91679ffa91f8

Check line number 97 to 103, this need to be modified after cloning this widget (this can change default value)

Check line number 137:

data.reqForQuery = gs.getProperty("glide.sc.request_for.query"); //this needs to be modified to achieve your dynamic list of users

Also once this is modified , this widget needs to be placed in sc catalog item widget, below is link :

/sp_config?id=widget_editor&sys_id=3c29786e87133200e0ef0cf888cb0bdf

Line number 34 on server script needs to be modified:

embeddedWidgetId: 'sc-checkout', //(name of cloned widget needs to be replaced here)

@gjz 

Please mark this correct and close this thread if this helped you.

Ankur Bawiskar
Tera Patron
Tera Patron

@gjz 

are you saying the super users should be allowed to edit the Request for as they are submitting request on behalf of someone?

If yes then check my below comment

1) create a group for those super users and add those super users under that group

2) create a superUserRole and assign to that group and then update the system property

There are two system properties which restrict the access to the "Requested For" field and therefore the cartJS.canViewRF() method.

glide.sc.req_for.roles
List of roles (comma-separated) that can update the "Requested for" widget in the service catalog. Blank means all users. If the user does not have privilege to change requested for, they will not have ability to get other user address details

glide.sc.req_for.roles.default
This property defines a default behavior when there are no roles given in property "glide.sc.req_for.roles". When the value is "allow" and the value of glide.sc.req_for.roles is empty, then any user can request items for other users. While the value is "deny" and the value of glide.sc.req_for.roles is empty then no user can request items for other users.

For your case you perform this

1) glide.sc.req_for.roles.default- allow

2) glide.sc.req_for.roles - superUserRole

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,

Yes, the super users need to be able to edit the Request for when they are submitting.  They already are in a group and they already have a role which I have already added to the property, but I need to limit the list of users to only the users in the same department as the super users.  There is already code created that has been used for the last 6 years that does that functionality, I'm trying to figure out how to make it work with checkout widget. I can do it with a reference field on the catalog item, but I need to do it on the widget.

 

javascript: new getDepartment().getDepartmentUsers()