iNBOUND ACTION
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 07:45 AM - edited 11-16-2023 08:00 AM
hi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 11:10 AM
Hi, I think your issue is that splitting the body_text with '&' results in 5 rows/elements,
with the last one being empty this is because you are creating an additional element for each occurrence of '&'
A few options to resolve
pop() the last element from the array.
Update your loop conditions to exclude the last element IE
for (var i = 1; i < rows.length - 1; i++)
You could also substring abc to remove the last '&' before you split.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 08:54 PM
HI @Deepthi13 ,
I trust you are doing great.
Please find the below corrected code for the same
(function runAction( /*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
var emailBody = email.body_text;
gs.log("@@@1 Raw Email Body: " + emailBody);
var rows = emailBody.split('&');
var rowCount = 0;
var disclaimer = "The contents of this e-mail and any attachment(s) may contain confidential or privileged information for the intended recipient(s)."; // Adjust this to match the start of your disclaimer text
for (var i = 1; i < rows.length; i++) { // Start loop from i = 1 to skip the header row
if (rows[i].indexOf(disclaimer) !== -1) {
gs.log("Skipping row containing disclaimer: " + rows[i]);
continue; // Skip creating sc_task for this row
}
var row = rows[i].split('\t');
var scTask = new GlideRecord('sc_task');
scTask.initialize();
var description = '';
// Concatenate details from the row to form the description
for (var j = 0; j < row.length; j++) {
description += row[j] + ' '; // Adjust this to format details as needed
}
scTask.short_description = 'Task for Ercu';
scTask.description = description.trim(); // Set the description field with row details
scTask.insert();
rowCount++;
}
gs.log("@@@ Total Rows Processed: " + rowCount);
})(current, event, email, logger, classifier);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 01:51 AM - edited 11-16-2023 04:23 AM
Hi Amit, @Amit Gujarathi @Amit Gujarathi
i am doing good, hope you are doing greate as well
The code u had given is correct, small more modification is required like in description i am getting output as
_________________________________________________________________________________________
Application Id :
Title : 2
First Name : Ms
Surname : Abel
Internal/External : Tutor
NI Number : External
Start Date : 222
Pension Employer Contribution : 14-12-2023
Pension Employee Contribution : 1232
: 1234
___________________________________________________________________________________________
BUT DESIRED OUTPUT:
Application Id : 2
Title : Ms
First Name : Abel
Surname : Tutor
Internal/External : External
NI Number : 222
Start Date : 14-12-2023
Pension Employer Contribution : 1232
Pension Employee Contribution : 1234
______________________________
using code:
sending below body in email
Application Id | Title | First Name | Surname | Internal/External | NI Number | Start Date | Pension Employer Contribution | Pension Employee Contribution | & |
1 | Mr | Sam | Ham | Internal | 1023 | 11-11-2023 | 2232 | 2223 | & |
2 | Ms | Abel | Tutor | External | 222 | 14-12-2023 | 1232 | 1234 | & |
3 | Mr | Ryan | Kelly | External | 231 | 15-01-2023 | 2314 | 1221 | & |
please suggest