
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 12:46 PM
Hello all,
I have a requirement to take a string field that is populated via our integration with Workday containing name data and split that field based on space as a delimiter and generate an email address to send out to a vendor.
the field on our SC_REQ_ITEM table is u_name.
As an example, this field will contain: Bob Smith
we need to convert that and email out what the email address will be: bob.smith@email.com
I've never tried to split a field based on space before especially in a mail script, so not sure this will even work. but, below is the mail script i'm attempting to run. unfortunately, the notification just shows a blank line where this mail script is, so i'm thinking it's failing before the template.print().
any thoughts would be greatly appreciated.
(function runMailScript(current, template, email, email_action, event) {
var nameID = sc_req_item.u_name + '';
var nameSplit = nameID.split(" ");
template.print('<p><font size="5" color="#f47641" face="helvetica">');
template.print("email: " + nameSplit[0] + "." + nameSplit[1] + "@maac.com");
template.print('</font></p>');
})(current, template, email, email_action, event);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 12:49 PM
I think it should work, but sc_req_item won't be assigned to anything in your script, perhaps you are trying to reference the current record?
(function runMailScript(current, template, email, email_action, event) {
var nameID = current.u_name + '';
var nameSplit = nameID.split(" ");
template.print('<p><font size="5" color="#f47641" face="helvetica">');
template.print("email: " + nameSplit[0] + "." + nameSplit[1] + "@maac.com");
template.print('</font></p>');
})(current, template, email, email_action, event);
Also, you may want to handle the case where there is no space in the name, in which case nameSplit[1] will be undefined and cause issues.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 12:49 PM
I think it should work, but sc_req_item won't be assigned to anything in your script, perhaps you are trying to reference the current record?
(function runMailScript(current, template, email, email_action, event) {
var nameID = current.u_name + '';
var nameSplit = nameID.split(" ");
template.print('<p><font size="5" color="#f47641" face="helvetica">');
template.print("email: " + nameSplit[0] + "." + nameSplit[1] + "@maac.com");
template.print('</font></p>');
})(current, template, email, email_action, event);
Also, you may want to handle the case where there is no space in the name, in which case nameSplit[1] will be undefined and cause issues.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 12:51 PM
That was it. I got so close. thanks for the second eyes!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2018 12:55 PM
sure thing!