Restrict a User to Submit a Catalog Item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 02:26 AM
Hi All,
Please help me with the below requirement:
If a Requested for has submitted a Request once, he cannot submit the request again for the same catalog item.
It should restrict the user and throw an error message. "You cannot submit a request".
Thanks and Regards,
Sweenal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 06:27 AM
You would need to create a client script to validate this (using GlideAJAX and a client callable script include). The client script can either be onLoad or onSubmit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 06:49 AM
Best way -> Hide the catalog item using user criteria if there is already a RITM for that catalog item for logged in user
This will avoid any client script or GlideAjax or any validation on that form
You can use advance script in user criteria
User criteria for Service Portal
var gr = new GlideRecord("sc_req_item");
gr.addQuery("cat_item.name", "Your Catalog Item Name Here");
gr.addQuery("request.requested_for", user_id);
gr.setLimit(1);
gr.query();
answer = !gr.hasNext();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 10:42 PM
Actually it should throw error message also that you can submit only one request.
and the script is not working i can see the the catalog item and submit the request after setting the limit also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 10:49 PM
Actually it should throw an error message that you cannot submit the catalog item if once you have submitted.
And the script which have given is not working i can see the catalog item and after setting the limit it is still showing the catalog item.