- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 05:58 AM
Hi there,
Not sure if I am missing something but we have two main types of users, users with the ITIL role and without the ITIL role. While having no roles, they are able to go onto our Service Portal and order things from there. This is expected behaviour.
I have had a need to automate a process where e-mails come in that either include a user's e-mail address in it or a shared mailbox's e-mail. If they are a user, it is to create an RITM under their name and send it to the correct assignment group. If they are not, it goes to a default user account and sent over (all this is to explain the code later).
When I send an e-mail in from my mailbox (an ITIL user) it works perfectly. If I send it from a non ITIL user mailbox however, nothing happens.
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Grabs a list of e-mails from the body text of the e-mail
var pulledEmail = email.body_text.match(/([a-zA-Z0-9._+-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
// Checks the User table for the user who has the first of the e-mails listed
// (which will be who needs e-mail released)
var userRec = GlideRecord("sys_user");
userRec.addQuery("email", pulledEmail[0]);
userRec.query();
// If it finds a User record with that e-mail, it will store that info.
// If not, it will put the default user in.
if (userRec.next()) {
var emailUserID = userRec.sys_id.toString();
}
else {
var emailUserID = '9a2561901b4a1910b4a70ed0f54bcb6c';
}
//Create a Service Portal "Cart" and put the Ironscales Quarantined Email form into it
var cart = new sn_sc.CartJS();
//Make the user found above the Requested For user and add the body of the e-mail into the Additional Comments
var newItem = cart.addToCart({
"sysparm_id": "09b419041b79b91006919828b04bcb29",
"sysparm_quantity": "1",
"variables":{
"additional_comments": email.body_text,
"caller_id": emailUserID
}
});
//Place the order and create the REQ and RITM for this Request.
var checkoutInfo = cart.checkoutCart();
//Find the RITM that was just created and update it with the Category, Subcategory and Assignment Group
var ritmRec = new GlideRecord("sc_req_item");
ritmRec.addQuery("request", checkoutInfo.request_id);
ritmRec.query();
if (ritmRec.next()) {
ritmRec.u_category = 'HES Applications';
ritmRec.u_subcategory = 'Ironscales';
ritmRec.assignment_group = '530c9e1edb085b001c7de2e15b9619f6';
ritmRec.update();
}
})(current, event, email, logger, classifier);
As mentioned before, non-ITIL user's can create RITMs thought the portal but they don't seem to be able to create them by e-mail. All the permissions seem to be the same so I'm not sure where this is going wrong. Any help would be most appreciated!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 08:59 AM
Are you using user criteria (available for / Not available for) on the specific catalog item that you are trying to order via this inbound action?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2024 08:59 AM
Are you using user criteria (available for / Not available for) on the specific catalog item that you are trying to order via this inbound action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 01:32 AM
Hi there Brian,
No, it's free of those. Without those being there, it seems that everyone can use them, ITIL and non-ITIL alike.
I could try making it so that the user that the e-mail will be coming in from is the only one that can use it. That might work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 02:36 AM
It seems that... YES, there was a user criteria active that was stopping it from running for non-ITIL users.
Rookie mistake! Thank you for pointing this out.