- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2024 11:19 PM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 06:58 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2024 06:58 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2024 04:13 AM
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