Restrict submit catalog item if short description and Requester is same

Samiksha2
Mega Sage

Hi All,

 

Users are creating request through emails. The requirement is to restrict to create request if short description and requested for is same. And the existing record is true.

I read some articles and posts but I didnt find the correct solution.

 

Please help.

 

Thanks,

Samiksha

17 REPLIES 17

Hi @Ankur Bawiskar ,

This is the inbound action to create request which I am using

Samiksha2_0-1695282515132.png

Short description is subject of the email.

 

 

@Samiksha2 

the way you are creating RITM is not correct. you should use Cart API so that you submit along with variables

you can get email subject using email.subject and also you can compare the recipient against the requested for and then query RITM table

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

Hi @Ankur Bawiskar ,

How to compare that? 

 

@Samiksha2 

I already told

Here is an example. I hope you will be able to enhance it further and mark my response as correct and close the thread.

try{
	var subject = email.subject;
	var user = email.from_sys_id;
	// now use GlideRecord to query
	var gr = new GlideRecord("sc_req_item");
	gr.addQuery("short_description", subject);
	gr.addQuery("requested_for", user);
	gr.setLimit(1);
	gr.query();
	if (!gr.next()) {

		var cartId = GlideGuid.generate(null);
		var cart = new Cart(cartId);
		//add your requested item to the cart by sys_id of the catalog item
		var item = cart.addItem('0336c34407d0d010540bf2508c1ed096', 1);

		//fill in the variables on the request item form
		cart.setVariable(item, "asset", "00a96c0d3790200044e0bfc8bcbe5dc3");
		cart.setVariable(item, "multiple_choice", "Phoenix");
		var rc = cart.placeOrder();
		gs.info(rc.number);
	}

}
catch(ex){
	gs.info(ex);
}

 

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

@Samiksha2 

Hope you are doing good.

Did my reply answer your question?

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