Attempting to update the Incident form via an email inbound action, but the action is not executing.

npeddiraju
Tera Contributor

I attempted to update my incident form using the email inbound action, but it isn't executing as expected. I’m unable to identify what went wrong. Please review the screenshots below and assist me in resolving the issue.

Thanks in advance  : ) 


Screenshot 2024-09-10 232200.pngScreenshot 2024-09-10 232210.pngScreenshot 2024-09-10 232240.pngScreenshot 2024-09-10 232310.png

 

(function runAction() {
    // Parse the subject to find the incident number
    var incidentNumber = email.subject.match(/INC\d+/); // Look for the incident number in the subject line

    if (incidentNumber) {
        // Get the incident record
        var incidentGR = new GlideRecord('incident');
        incidentGR.get('number', incidentNumber[0]); // Find the incident by its number
        gs.log("Incident no: " + incidentNumber);
       

        if (incidentGR.isValidRecord()) {
            // Update fields based on email content
             gs.log("Incident Found: " + incidentGR.number);
            incidentGR.u_customer_input = email.body_text; // Set the customer input from the email body text
            incidentGR.short_description = incidentGR.short_description + " " + email.body_text; // Set the short description from the email body text
            incidentGR.comments = email.body_text; // Add the email body to the incident comments
            incidentGR.update(); // Save the record
        } else {
            gs.log("Incident not found: " + incidentNumber[0]);
        }
    } else {
        gs.log("No incident number found in the email subject.");
    }
})();


0 REPLIES 0