- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2021 04:39 PM
Hello Community,
I have found many articles on this, and none have figured this out for me. So we need to parse "Employee Name" == "[user name]" into the Caller field in an incident.
The email HTML that comes in is:
<tr>
<td valign="top" style="font-weight: bold;padding-top:10px;padding-bottom:10px;border-bottom: 1px solid #E6E6E6; width: 100px;">Employee Name</td>
<td width="25px" ;="" style="border-bottom: 1px solid #E6E6E6;"></td>
<td style=" padding: 10px 5px 10px 5px; border-bottom: 1px solid #E6E6E6; font-family:Arial,'Segoe UI Emoji','Segoe UI Symbol'; font-size:10pt; color:#000000; font-weight:normal; font-style:normal; text-decoration:none; background-color:#FFFFFF;padding-left:8px; font-weight:bold; background-color:#FEFF85; ">Nathan Test 2</td>
</tr>
This is how it looks in the body of a received incident:
So far I've tried a number of things and they haven't worked.
My current Inbound Action: Action stands here:
Any help will be much obliged! I will mark helpful etc!
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2021 04:57 PM
Hey Community. Would love some more help if possible.
I did try this, this was very helpful:
Here I essentially used it to do some "email processing" so that I can get a big lumpy string of characters and used it to test. Once i was able to get the exact variables I needed I disregarded the indesReg and finalvalue steps...
I need this to now populate the "Caller" reference field. But, i'm having no luck.
Now, this looks like this:
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
//Processing Email HTML - TEST1
var htmlcode=email.body_html;
htmlcode = htmlcode.replace(/<style([\s\S]*?)<\/style>/gi, '');
htmlcode = htmlcode.replace(/<script>/gi, '');
htmlcode = htmlcode.replace(/<\/div>/ig, '\n');
htmlcode = htmlcode.replace(/<\/li>/ig, '\n');
htmlcode = htmlcode.replace(/<li>/ig, ' * ');
htmlcode = htmlcode.replace(/<\/ul>/ig, '\n');
htmlcode = htmlcode.replace(/<\/p>/ig, '\n');
htmlcode = htmlcode.replace(/<br\s*[\/]?>/gi, "\n");
htmlcode = htmlcode.replace(/<[^>]+>/ig, '');
htmlcode=htmlcode.replace(' ','');
htmlcode=htmlcode.replace(/\r?\n|\r/g,'');
gs.log("final email String "+htmlcode);
//ends processing
var indesREG = new SNC.Regex('/Employee:.*Request Received/si'); // this line will get the value of string between Employee Name and Request Received
//do not use finalvalue, the above processing is good enough to collect the employeename natively.
var finalvalue = indesREG.match(htmlcode).toString();
//test 1b - This will get the correct data.
var employee_name = email.body.employee;
//populate the caller reference field...
current.caller.setDisplayValue(employee_name); //does not work!! what the heck
//populate a string field for testing
current.u_reentry_caller=employee_name;
//the rest of the journey
current.comments = "Email received from: " + email.origemail;
current.short_description = email.subject + ' test1 ' + employee_name;
current.description = email.body_text;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2021 08:39 PM
Try using email.from_sys_id
email.from_sys_id | Contains the Sys ID of the user who sent the email to the instance. |
current.caller_id=email.from_sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2021 08:24 AM
Hi
Unfortunately, this won't work, as we are receiving email alerts that are being generated from another system. The emails are not being sent from the employee, the emails are being sent for this example automation@abc.com. (@abc.com is not our domain).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2021 04:57 PM
Hey Community. Would love some more help if possible.
I did try this, this was very helpful:
Here I essentially used it to do some "email processing" so that I can get a big lumpy string of characters and used it to test. Once i was able to get the exact variables I needed I disregarded the indesReg and finalvalue steps...
I need this to now populate the "Caller" reference field. But, i'm having no luck.
Now, this looks like this:
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
//Processing Email HTML - TEST1
var htmlcode=email.body_html;
htmlcode = htmlcode.replace(/<style([\s\S]*?)<\/style>/gi, '');
htmlcode = htmlcode.replace(/<script>/gi, '');
htmlcode = htmlcode.replace(/<\/div>/ig, '\n');
htmlcode = htmlcode.replace(/<\/li>/ig, '\n');
htmlcode = htmlcode.replace(/<li>/ig, ' * ');
htmlcode = htmlcode.replace(/<\/ul>/ig, '\n');
htmlcode = htmlcode.replace(/<\/p>/ig, '\n');
htmlcode = htmlcode.replace(/<br\s*[\/]?>/gi, "\n");
htmlcode = htmlcode.replace(/<[^>]+>/ig, '');
htmlcode=htmlcode.replace(' ','');
htmlcode=htmlcode.replace(/\r?\n|\r/g,'');
gs.log("final email String "+htmlcode);
//ends processing
var indesREG = new SNC.Regex('/Employee:.*Request Received/si'); // this line will get the value of string between Employee Name and Request Received
//do not use finalvalue, the above processing is good enough to collect the employeename natively.
var finalvalue = indesREG.match(htmlcode).toString();
//test 1b - This will get the correct data.
var employee_name = email.body.employee;
//populate the caller reference field...
current.caller.setDisplayValue(employee_name); //does not work!! what the heck
//populate a string field for testing
current.u_reentry_caller=employee_name;
//the rest of the journey
current.comments = "Email received from: " + email.origemail;
current.short_description = email.subject + ' test1 ' + employee_name;
current.description = email.body_text;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2021 02:43 PM
To complete the Caller step i used a business rule... all done 🙂