Extract the table information from the body of email to populate in Alert/Incident description

Dhana1
Tera Contributor

Hi,

 

We are trying to Integrate SAP Cloud with Service Now Event Management module which means

 

1)Alert generated form SAP Cloud and sent to ServiceNow
2)ServiceNow processes it, creates and alert, creates an incident.


I need help on Inbound action script to get the information from body of email...Need to extract the table data which contains affected system entity details and that needs to be populated in Event description which will reflect the same in Alert/Incident.

 

Note: We need to extract the table data which is at the end of the email body....Please help with the string separation script in Inbound Action.

 

2 REPLIES 2

Mani A
Tera Guru

 

var emailBody = email.body;

var regex = /Product Name([\s\S]*?)(?=Questions?)/;

var match = emailBody.match(regex);

if (match && match[1]) {

    var extractedData = match[1].trim();

    var lines = extractedData.split('\n');

    var eventDescription = '';

    for (var i = 0; i < lines.length; i++) {

        var line = lines[i].trim();

        if (line) {

            eventDescription += line + '\n';

        }

    }

  current.description = eventDescription;

    gs.log("Extracted Data: " + eventDescription);

} else {

    gs.log("No affected entity data found in the email body.");

}

 

Dhana1
Tera Contributor

Hi Mani,

 

Thanks for your reply.

I have tried this script in Inbound Action and eventDescription field value to be populated in Event 'additional_info' field able to get the Product name details but when trying to create an event rule unable to get the additional info in the event rule.

 

Can you help me why additional_info is missing when creating an event rule