Restrict a User to Submit a Catalog Item.

Sweenal
Tera Contributor

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

7 REPLIES 7

Mike_R
Kilo Patron
Kilo Patron

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.

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Sweenal 

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.

 

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

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.

@Ankur Bawiskar 

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.