how to generate a req,ritm and sc task via inbound email action

raj765_32
Tera Contributor

hi can anyone please help me with scenario for the inbound email action i created when receipient contains ****.com,

i have given the email condition when the recipients contain for email address and action type as 'record action' and type as new and in the actions tab i have written the below code , i have created a ctalog item and workflow for this.. below the code:

 

var cart = new Cart();
    var item = cart.addItem('9710702cc3840210669f9e8f05013154');
    cart.setVariable(item, 'additional_info_noc', email.body_text.toString());
    var rc = cart.placeOrder();
var emailSubject = email.subject.toString();
    if (rc != undefined) {
        var gr1 = new GlideRecord("sc_req_item");
        gr1.addQuery("request", rc.sys_id);
        gr1.query();
        if (gr1.next()) {
            sys_email.target_table = "sc_req_item";
            sys_email.instance = gr1.sys_id;
            sys_email.update();
        }
 
        var req = rc.sys_id;
        var r = new GlideRecord('sc_req_item');
        r.addQuery('request.sys_id', req);
        r.query();
        if (r.next()) {
            r.contact_type = 'Email';
            r.update();
        }
    } 
 
 
event.state = "stop_processing";
4 REPLIES 4

Ivan Betev
Mega Sage
Mega Sage

Hi @raj765_32 ,

 

I've made a couple of videos about it, maybe they will help, please check them:

https://youtu.be/3vX-I3gt4Ps?si=jocoaslUOKc0WsL0

https://youtu.be/pbFzD1dNfpg?si=fbf-cNozmaJbt5e-

 

Regards, Ivan

hi ivan surely i will follow the videos, but for a time being can you please tell me the defect in my code and why it is not creating a req and ritm

Ivan Betev
Mega Sage
Mega Sage

Hi @raj765_32 ,


This part should place request, and it is correct:

var cart = new Cart();
var item = cart.addItem('9710702cc3840210669f9e8f05013154');
cart.setVariable(item, 'additional_info_noc', email.body_text.toString());
var rc = cart.placeOrder();

 

If that is not happening then your Inbound Action is not getting triggered. What is shown in the email log itself when it comes in? Is the order correct?

 

What are you trying to do in this part? Associate an email with a target record? What is the sys_email? There is no such a parameter in Inbound action => this should give you an error at least.

var gr1 = new GlideRecord("sc_req_item");
    gr1.addQuery("request", rc.sys_id);
    gr1.query();
    if (gr1.next()) {
        sys_email.target_table = "sc_req_item";
        sys_email.instance = gr1.sys_id;
        sys_email.update();
    }

 

Regards, Ivan

im not getting any error anyhow and i have watched your video on flow designer and is not working for me..