Inbound action data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 03:51 AM
Hi Team,
I am trying to set the data from inbound action in to description and (name-value pair) field with the data sent from in the excel. but description and name-value pair key both are not working properly. please suggest
Script:
The email excel format i am sending:
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 | & |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 07:02 AM
(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
// Extract header row
var headerRow = rows[0].split('\t');
for (var i = 1; i < rows.length; i++) { // Start loop from i = 1 to skip the header row
if (rows[i].indexOf(disclaimer) !== -1) {
// Skip rows containing disclaimer text
gs.log("Skipping row containing disclaimer: " + rows[i]);
continue;
}
var row = rows[i].split('\t');
var scTask = new GlideRecord('sc_task');
scTask.initialize();
var description = '';
// Construct the description by pairing each header name with its corresponding value in the row
for (var j = 0; j < headerRow.length; j++) {
description += headerRow[j] + ' : ' + row[j] + '\n'; // Format: HeaderName : Value
}
scTask.short_description = 'Task for Ercu';
scTask.description = description.trim(); // Set the description field with row and header details
scTask.insert();
rowCount++;
}
gs.log("@@@ Total Rows Processed: " + rowCount);
})(current, event, email, logger, classifier);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 07:22 AM
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 | & |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 09:09 PM
HI @Deepthi13 ,
I trust you are doing great.
Here's a revised version of your script with added comments for clarity:
(function runAction(current, event, email, logger, 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..."; // Disclaimer text
// Extract header row
var headerRow = rows[0].split('\t');
for (var i = 1; i < rows.length; i++) {
if (rows[i].indexOf(disclaimer) !== -1) {
gs.log("Skipping row containing disclaimer: " + rows[i]);
continue;
}
var row = rows[i].split('\t');
if (row.length < headerRow.length) {
gs.log("Skipping incomplete row: " + rows[i]);
continue; // Skip rows with fewer columns than headers
}
var scTask = new GlideRecord('sc_task');
scTask.initialize();
var uDataString = '';
var description = '';
for (var j = 0; j < headerRow.length; j++) {
var headerName = headerRow[j];
var value = row[j] || ''; // Handle missing values
uDataString += headerName + ' : ' + value + '\n';
description += headerName + ' : ' + value + '\n';
}
scTask.short_description = 'Task for Ercu';
scTask.u_data = uDataString.trim();
scTask.description = description.trim();
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-26-2023 11:59 PM