Description Field empty when Email Is sent create incident record

ADJARATOUT
Tera Contributor

Hi,
When an email is sent, an incident record is created, but the description field is empty in the incident record, while the body of the email is not empty.

ADJARATOUT_0-1771166605667.png

 

1 REPLY 1

Srikanth_9
Tera Expert

Hi @ADJARATOUT,

 

I have created the custom Inbound Email Action in my PDI. I'm sharing the script here, please try this and check it.

 

(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
 
    //To get caller from email address
    var caller = new GlideRecord('sys_user');
    caller.addQuery('email',email.from);
    caller.query();
    if(!caller.next()){
        gs.log("No matching user for email: " + email.from); //Caller not found, optionally log or assign default
    }

    //Create Incident
    var inc = new GlideRecord('incident');
    inc.initialize();
    inc.short_description = email.subject || "No Subject";
    inc.description = email.body_text || "No description provided";

    //If caller was found, assign it
    if(caller.isValidRecord()){
        inc.caller_id = caller.sys_id;
    }

    //Set default values
    inc.category = 'inquiry';
    inc.impact = 3;
    inc.urgency = 3;

    var incidentID = inc.insert();

    //gs.log("Incident created from email: " + incidentID);


})(current, event, email, logger, classifier);
 
 
If the provided solution is useful/working, please Accept as Solution and hit the Helpful. 
 
Thanks & Regards,
Srikanth Akula.