Inbound Action

tomaslindev
Mega Guru

Hello everyone,
I need to create an Inbound Action so that after a response from an email containing "@example.com" or "@examplecompany.com" the INC will be set to "Work in Progress". I had to integrate this functionality into another colleague's Inbound Action and I would like to know if you see any errors.
Thank you very much and best regards.

 

gs.include('validators');

if (current.getTableName() == "incident") {
    
    var gr = current;
    
    if (email.subject.toLowerCase().indexOf("please reopen") >= 0)
        gr = new Incident().reopen(gr, email) || gr;
    
    gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;
    
    // Respuesta del proveedor
    if (gr.state == 3 && gr.u_vendor.email == email.origemail) {
        gr.state = 2;
    }

    // Cambio de estado a "Work in Progress" si el correo es de @Example.com o @examplecompany.com
    var senderEmail = email.origemail.toLowerCase();
    if (senderEmail.includes("@minsait.com") || senderEmail.includes("@indracompany.com")) {
        gr.state = 2; // Work in Progress
    }

    if (gs.hasRole("itil")) {
        if (email.body.assign != undefined)
            gr.assigned_to = email.body.assign;
        
        if (email.body.priority != undefined && isNumeric(email.body.priority))
            gr.priority = email.body.priority;
    }
    gr.update();
}
1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

I don't see any obvious errors in what appear to be your additions to the code and it seems like you followed the original format well. 

Provided the conditions for the inbound action are appropriate, this should function. 

If you see a need for this to be more scalable (adding other addresses) there are some suggestions I would make, like using a system property to hold an array of strings to check and then iterating through the array rather than hard coding just two check, but only if you see the possibility of adding or modifying what you are checking later. 


I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

2 REPLIES 2

21121A3359
Tera Contributor

gs.include('validators');

if (current.getTableName() == "incident") {
var gr = current;
var senderEmail = email.origemail.toLowerCase();

if (email.subject.toLowerCase().indexOf("please reopen") >= 0) {
gr = new Incident().reopen(gr, email) || gr;
}

gr.comments = "reply from: " + email.origemail + "\n\n" + email.body_text;

// Change state if vendor email matches
if (gr.state == 3 && gr.u_vendor.email && gr.u_vendor.email.toLowerCase() == senderEmail) {
gr.state = 2; // Work in Progress
}

// Change state if the email is from the specified domains
if (senderEmail.includes("@example.com") || senderEmail.includes("@examplecompany.com")) {
gr.state = 2; // Work in Progress
}

if (gs.hasRole("itil")) {
if (email.body.assign) gr.assigned_to = email.body.assign;
if (email.body.priority && isNumeric(email.body.priority)) gr.priority = email.body.priority;
}

gr.update();
}

once try this

Michael Jones -
Giga Sage

I don't see any obvious errors in what appear to be your additions to the code and it seems like you followed the original format well. 

Provided the conditions for the inbound action are appropriate, this should function. 

If you see a need for this to be more scalable (adding other addresses) there are some suggestions I would make, like using a system property to hold an array of strings to check and then iterating through the array rather than hard coding just two check, but only if you see the possibility of adding or modifying what you are checking later. 


I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!