How Restrict the User to only one Request per catalog item?

Gowtham Kodali
Tera Contributor

 how can we restrict the user to only one request per catalog item if he has already  an existing open request  for that catalog item.

for example 

If a user has an open request on  catalog item  'X' again he is trying to raise the request  for the same catalog item i want to restrict him from raising the request in such case how is it possible

15 REPLIES 15

asifnoor
Kilo Patron

Hello Gowtham,

Create a on Before insert BR on sc_req_item

Conditions

Item is <your_cat_item> AND

state is open

Actions:

Select Abort Action

Add message : you already have a opened RITM.

Save

Mark the comment as a correct answer and also helpful if it helps to solve the problem.

I tried this but REQ#####  is generating in the Portal but RITM is not being created is there any way to prevent the REQ### also

Do you want to stop creating the request itself or can you close the request as rejected if ritm exists?

If thats the case, then you can do it like this

In the above BR select advanced and under script add this code

var gr = new GlideRecord("sc_request");
if(gr.get(current.request)) {
  gr.request_state= "closed_rejected";
  gr.update();
}
gs.addErrorMessage("Request already exists for this user");
current.setAbortAction(true);

Mark the comment as a correct answer and also helpful if it helps to solve the problem.

Hi @asifnoor ,

I have similar requirement. Please help me.  I have posted my question:
https://www.servicenow.com/community/now-platform-forum/restrict-submit-catalog-item-if-short-descri...

 

Thanks,

Samiksha