How to convert template data into inbound action for creation incident

Kat123
Tera Contributor

Kat123_0-1755244954917.png

 

I will get above template from user in email

what script we will use for converting this data into incident 

7 REPLIES 7

Bhuvan
Kilo Patron
Catalog Items are just a way to define inputs and launch flow. There are many reasons why the catalyst may be email. STEP BY STEP - Create the Catalog Flow as if you assumed form entry. - Create a new Flow Action to parse an email body for name:value pairs (OR download from share) - Create a ...
"Unlock the full potential of ServiceNow with our latest video tutorial on email parsing for reference fields! Learn how to seamlessly integrate incoming email data into your ServiceNow platform, enhancing efficiency and accuracy. For a comprehensive guide, check out this helpful document: [Link ...

Kat123
Tera Contributor

like i will use normal script for getting project value -

if (email.body.projectt != undefined) {
current.u_project = email.body.project;
}

 so i will receive data through email in html format (in table format, like rows and columns)

so how i can convert tabular data or table format data into incident via inbound action.

what changes in script needed

Raghu Ram Y
Kilo Sage

@Kat123 Please try the below script. For this sample, I mapped Title to Short Description and Project to Description. You can replace them with the relevant fields as needed.

    var htmlBody = email.body_html;
    var parser = new GlideXMLUtil();
    var doc = parser.parse(htmlBody);

    var title = "";
    var project = "";

    var rows = doc.getElementsByTagName("tr");

    for (var i = 0; i < rows.getLength(); i++) {
        var cells = rows.item(i).getElementsByTagName("td");
        if (cells.getLength() >= 2) {
            var label = cells.item(0).getTextContent().trim().toLowerCase();
            var value = cells.item(1).getTextContent().trim();

            if (label.indexOf("title") > -1) {
                title = value;
            }
            if (label.indexOf("project") > -1) {
                project = value;
            }
        }
    }

    var inc = new GlideRecord("incident");
    inc.initialize();
    inc.short_description = title || "No Title Provided";
    inc.description = project || "No Project Provided";
    inc.insert();

  

not creating incident 

getting 'Incident Creation : did not create or update incident using current ' in email log