- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-22-2020 01:57 PM
Hi all,
I have been tasked with triggering the submission of a catalog item when an email is received.
I don't have much of a coding background so I'm sure the problem is somewhere or something to do with my code...
Here is my current inbound action below:
Target table: sc_req_item
Action type: Record Action
Script:
createRequest();
function createRequest() {
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('65fcbfee75642400af0e5269def2e168');
cart.setVariable(item, 'sn_req_app', '1');
cart.setVariable(item, 'sn_req_details', 'Sample text');
var rc = cart.placeOrder();
}
A few other points:
- There are no field actions, just the above script
- I have ensured that in my email submission tests, the condition to trigger the inbound action is correct
- The sys_id is pointing to an active test catalog item with only 2 variables both of which are non-mandatory
- Global scope
What I have found is, when the email is received, I get the following mesage in the email log: "Information - Skipping 'inbound_action_name', did not create or update sc_req_item"
In testing I have also noticed that if I place a field action along with the script (for example, Short Description - From email - Subject) it will generate a blank RITM record with no Item attached.
Any help on this would be much appreciated!
Thank you,
Bernard
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-23-2020 05:14 AM
That is all correct. Target table should be Request.
Change your script to look like this:
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('65fcbfee75642400af0e5269def2e168');
cart.setVariable(item, 'sn_req_app', '1');
cart.setVariable(item, 'sn_req_details', 'Sample text');
var rc = cart.placeOrder();
var ritmRec = new GlideRecord("sc_req_item");
ritmRec.addQuery("request", rc.sys_id);
ritmRec.query();
if (ritmRec.next()) {
ritmRec.short_description = email.subject.toString();
ritmRec.comments = "received from: " + email.origemail + "\n\n" + email.body_text;
ritmRec.contact_type = "email";
ritmRec.update();
}
//update target in email table, as it won't be updated as the record was inserted through cart API
if (rc != '') {
var email_rec = new GlideRecord('sys_email');
email_rec.get(sys_email.sys_id);
email_rec.instance = rc.sys_id;
email_rec.target_table = "sc_request";
email_rec.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-23-2020 02:03 PM
This worked great š !
Thank you for your help on this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-23-2020 03:15 PM
You're welcome - glad it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-26-2020 12:56 AM
Hi Michael,
I am also facing similar issue.I want to trigger a notification from the inbound email action.It's not working,could you check once
Here is my script:
var ritmNo ='';
var sub=email.subject;
var req='';
var index = sub.indexOf("RITM");
var end = 11; //length of ritm
if(index > -1) {
end = index+end;
ritmNo = sub.substring(index, end).trim();
gs.log(ritmNo);
}
//if (current.getTableName() == "sc_req_item") {
//if (email.subject.toLowerCase().indexOf("RITM") > -1)
// if(email.from_sys_id == current.u_requested_for)
// {
// req= current.u_requested_for;
// }
var body=email.body_text;
var boo=[];
boo=body.split('________________________________');
var gr=new GlideRecord('sc_req_item');
gr.addActiveQuery();
gr.addQuery('number',ritmNo);
gr.query();
if(gr.next())
{
//gs.eventQueue('Test Email',gr,email.from,finalVal);
if(email.from_sys_id == gr.u_requested_for)
{
req= gr.u_requested_for;
}
var finalVal=sub+"|"+boo[0]+"|"+req;
gs.eventQueue('Test Email',gr,email.from,finalVal);
}
// req=gr.u_requested_for;
//gs.eventQueue('Test Email',current,email.from,finalVal);
gs.log("tttttttttt"+boo[0]);
//current.update();
//}
In email Log.
I changed current also but still i am getting same error.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-20-2020 04:38 PM
Miachael, this is great and I have my inbound action creating the REQ/RITM/TASK. I'm not however able to set the requested_for or opened_by field. Bothe are blank. I'm sure it's a sytax thing and I'm using -
cart.setVariable(item, 'requested_for', '3e43f265db00bb00298177298c961946');
Any thoughts? Anyone?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-21-2020 05:47 AM
Confirming you have a variable named - requested_for - on your catalog item?