Trying to trigger catalog item (and workflow) from inbound email action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 04:22 PM
I'm working on trying to trigger a catalog item (and the associated workflow) via an inbound email action. I've got to where it will create the request and RITM are created but the workflow and catalog items don't get created. Here's my script:
createRequest();
function createRequest() {
//Create Request
var grRequest = new GlideRecord("sc_request");
grRequest.initialize();
grRequest.requested_for = '5136503cc611227c0183e96598c4f706';
grRequest.short_description = email.subject.toString();
grRequest.description = "received from: " + email.origemail + "\n\n" + email.body_text;
var requestSysId = grRequest.insert();
//Create Request Item
current.requested_for = '95a20ff34776301063df0923846d431d';
current.short_description = email.subject.toString();
current.description = "received from: " + email.origemail + "\n\n" + email.body_text;
current.cat_item = '570b0c4e97358d1030fd307e6253afaf';
current.parent = requestSysId;
current.request = requestSysId;
current.insert();
}
I've been going around in circles with this for a while now and it's making me crazy! Any help is greatly appreciated!!
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 12:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 12:53 PM
Hello Keith,
Interesting error message, the only thing that I seem to find is this. My guess is you're having a conflict with this if there's no User record: "Note that emails from external users that have no User[sys_user] record on the system (e.g. <someone>@gmail.com where there is no User record with Email=<someone>@gmail.com) are processed as the instance's internal guest user."
Try the resolution suggestions in the above KB and see if it helps anything, if not, I'd go to the service portal impersonating whoever the user is you tested sending the email with (assuming they have a User record in your environment) and see if an item is just stuck in the cart you can manually delete and then retry.
Please mark my answer as correct/helpful if it has helped you.
Thanks,
Logan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 04:28 PM
Hi,
You should use cart API.
Please refer the below script for the same.
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem("8f58101edbc2ac10c2937b276896195b");//Sys_id of catalog
cart.setVariable(item, "requested_for", current.getUniqueValue());//variables
cart.setVariable(item, "delete_type", gr.u_type);
cart.setVariable(item, "extension", gr.sys_id.toString());
cart.setVariable(item, "shortname", current.user_name);
cart.placeOrder();
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
Regards,
Saurabh
Thanks and Regards,
Saurabh Gupta