- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 03:08 PM
Hello Guys, I was attempting to pull a specfic line after the last : that starts with
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 07:18 PM
Can you log the email body to inspect the content you getting in that, Also Depending on the format of your email body, you might need to adjust the regular expression. For instance, if there could be whitespace characters around the = sign or the : sign, you might want to make the expression more flexible.
Please try the updated code below:
var emailBody = email.body_text;
gs.info("Email Body: " + emailBody); // Log the email body to inspect its content
// Adjusted regular expression to be more flexible
var regex = /UniqueFailureID\s*=\s*.*:([a-f0-9\-]+)$/im;
var match = emailBody.match(regex);
if (match && match[1]) {
var uniqueFailureID = match[1];
current.u_uniquefailureid = uniqueFailureID;
current.update();
} else {
gs.log("UniqueFailureID not found in the email body for incident: " + current.number, "Inbound Email Action AAC_Automation");
}
lease Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 03:16 PM - edited 02-26-2024 04:56 PM
Can you try something like this?
var emailBody = email.body.text;
var match = emailBody.split(':');
if (emailBody.indexOf('uniqueFailureID')>-1) {
for (var i=0;i<match.length;i++)
{
var uniqueFailureID = match[i].split('=');
current.u_uniquefailureid = uniqueFailureID[1];
current.update();
}
} else {
gs.info("UniqueFailureID not found in the email body for incident: " + current.number, "Inbound Email Action AAC_Automation");
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 07:06 AM
I am still unable to transition any data from incoming emails with your proposed solution. It just reverts to the error message in the else. The incoming emails has multiple items besides the specific value I'm attempting to bring in. the full value of the line that is in the text is "UniqueFailureID=PROD:SystemLegacy:AdviceWorks:ea17cf9a-4773-4400-9fa9-216f74ce3bcf"
This value comes at the very end of the email body. I would like to fill in the line after the last : but it seems any variations i attempt fail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 04:48 PM
First you can check if the 'UniqueFailureID exists in the text using
var exist=string.indexOf('UniqueFailureID');
if it exists it gives the index of that value, if doesnot exist it gives -1
If the index for example is 2 then you can use
string.substring(2) it will extract all the values of string from that value till the end of the string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 07:18 PM
Can you log the email body to inspect the content you getting in that, Also Depending on the format of your email body, you might need to adjust the regular expression. For instance, if there could be whitespace characters around the = sign or the : sign, you might want to make the expression more flexible.
Please try the updated code below:
var emailBody = email.body_text;
gs.info("Email Body: " + emailBody); // Log the email body to inspect its content
// Adjusted regular expression to be more flexible
var regex = /UniqueFailureID\s*=\s*.*:([a-f0-9\-]+)$/im;
var match = emailBody.match(regex);
if (match && match[1]) {
var uniqueFailureID = match[1];
current.u_uniquefailureid = uniqueFailureID;
current.update();
} else {
gs.log("UniqueFailureID not found in the email body for incident: " + current.number, "Inbound Email Action AAC_Automation");
}
lease Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks