Inbound Email action

Surya61
Tera Contributor

Hi All,

 

I have a requirement whenever email receives to outlook whenever subject contains error or warning i'm creating an incident in servicenow for the following alert in the email body contains text like below format and i want to map the service value to the cmdb_ci field in incident form service will be changes for each of the email 

Singnal Type        Metric
Severity    Sev1
Service     individualregistrationaccountserviceprdperformase
1 ACCEPTED SOLUTION

Najmuddin Mohd
Mega Sage

Hi @Surya61 ,
How do you define the uniqueness of the Service. 
Are you sure that the name of the Services are unique, then you can write a regex on it to get the value of the service an store it a variable.

Now, glideRecord the cmdb_ci table and query with the variable (that stores the Service Value) and now map it's gr.sys_id to cmdb_ci field, since cmdb_ci field is reference field.

Try the below in the Scripts - Background, 

var emailBody = 'Singnal Type        Metric Severity    Sev1 Service  individualregistrationaccountserviceprdperformase ';

var regex = /Service\s+([a-zA-Z0-9]+)/;
var match = emailBody.match(regex);

if (match) {
    var serviceValue = match[1];
    gs.info('Service Value: ' + serviceValue);
} else {
    gs.info('Service value not found');
}


Output:

*** Script: Service Value: individualregistrationaccountserviceprdperformase


If this information helps you, Kindly mark it as Helpful and Accept the solution.

Regards,
Najmuddin.

View solution in original post

2 REPLIES 2

Najmuddin Mohd
Mega Sage

Hi @Surya61 ,
How do you define the uniqueness of the Service. 
Are you sure that the name of the Services are unique, then you can write a regex on it to get the value of the service an store it a variable.

Now, glideRecord the cmdb_ci table and query with the variable (that stores the Service Value) and now map it's gr.sys_id to cmdb_ci field, since cmdb_ci field is reference field.

Try the below in the Scripts - Background, 

var emailBody = 'Singnal Type        Metric Severity    Sev1 Service  individualregistrationaccountserviceprdperformase ';

var regex = /Service\s+([a-zA-Z0-9]+)/;
var match = emailBody.match(regex);

if (match) {
    var serviceValue = match[1];
    gs.info('Service Value: ' + serviceValue);
} else {
    gs.info('Service value not found');
}


Output:

*** Script: Service Value: individualregistrationaccountserviceprdperformase


If this information helps you, Kindly mark it as Helpful and Accept the solution.

Regards,
Najmuddin.

Surya61
Tera Contributor

Hi Najmuddin,

 

with the above information i'm able to create an incident and ci also populating in incident my next question is like if we get resolved email for the same service i want to co relate with existing incident and auto resolve the incident in servicenow