outputs not showing in action script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 08:11 AM
Here is the action script code, i have an email body as the input, it parse the data effectively and i want to output that data, but it keeps coming back empty when running test but works when running a background test script.
(function execute(inputs, outputs) {
function htmlToStr(html) {
var noHTML = html.replace(/<br(?:\s*)?\/?>/gi, "\n").replace(/(<([^>]+)>)/ig, '');
return decodeURI(noHTML);
}
var emailBody = htmlToStr(inputs.email.toString());
var keyValuePattern = /([a-zA-Z0-9_-]+)\s*:\s*([^\n]+)/g;
var keyValuePairs = {};
var match;
// Iterate through matches and populate the keyValuePairs object
while ((match = keyValuePattern.exec(emailBody)) !== null) {
var key = match[1].trim();
var value = match[2].trim();
keyValuePairs[key] = value;
}
// Now you can use the keyValuePairs object to access the parsed data
gs.info("Parsed Key-Value Pairs:");
for (var key in keyValuePairs) {
gs.info(key + ": " + keyValuePairs[key]);
}
//outputs.email_var = keyValuePairs;
outputs.country = keyValuePairs['country'];
})(inputs, outputs);
0 REPLIES 0