- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 06:00 AM
Hello Experts,
Can you please assist how do I parse the value from the below subject line and put in Incident fields
Windows Alert::DeviceDown::GH56CCVNH.aeb.ca::10.12.212.14::critical
I want GH56CCVNH in Configuration Item field
and critical as P1 in Priority field.
Can anyone assist how to extract them
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 06:11 AM
@Nisha30 Please try something like below.
var subject = email.subject;
var subjectParts = subject.split("::");
var ci = subjectParts[2].split(".")[0];
var priority = subjectParts[4].toLowerCase() == 'critical' ? 1 : 3;
current.cmdb_ci = getCI(ci);
current.priority = priority;
function getCI(ciName) {
var ciRecord = new GlideRecord('cmdb_ci');
ciRecord.addQuery('name', ciName);
ciRecord.query();
if (ciRecord.next()) {
return ciRecord.sys_id;
}
return null;
}
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 06:11 AM
@Nisha30 Please try something like below.
var subject = email.subject;
var subjectParts = subject.split("::");
var ci = subjectParts[2].split(".")[0];
var priority = subjectParts[4].toLowerCase() == 'critical' ? 1 : 3;
current.cmdb_ci = getCI(ci);
current.priority = priority;
function getCI(ciName) {
var ciRecord = new GlideRecord('cmdb_ci');
ciRecord.addQuery('name', ciName);
ciRecord.query();
if (ciRecord.next()) {
return ciRecord.sys_id;
}
return null;
}
Please mark my answer correct and helpful if this works for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 06:28 AM - edited 10-18-2024 06:33 AM
Thanks @Gangadhar Ravi it worked perfectly. Thanks for instant response.
Just one thing about priority what is meant by 1:3 ? here It is P4 coming as per this code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 07:05 AM
The expression 1 : 3 is used in a quick "if-else" check:
- If the condition is true (in this case, if the word is "critical"), it sets the value to 1.
- If the condition is false (anything else), it sets the value to 3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2024 06:34 AM
@Gangadhar Ravi so the priority is always setting to p4 here as per this code .
so here actually
if critical it should be P1
If medium- P3
If low- P4
If High-P2
Can you assist on this
Thanks