Restrict submit catalog item if short description and Requester is same
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 07:45 PM
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
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 12:49 AM
Hi @Ankur Bawiskar ,
This is the inbound action to create request which I am using
Short description is subject of the email.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 03:00 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 03:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 04:00 AM
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);
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 11:16 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader