
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2018 02:49 PM
Hi All,
I have a requirement where I need to replace the 'Approval' email to use the HR teams email and not the IT team email. The out of the box approve message has a link to approve and reject via email. These have a link 'Click here to Approve <number>' which opens a reply email with a default reply email, subject and includes the original watermark.
I have created a business rule, before, insert, on sys_email table to check for text and replace, see below:
(function executeRule(current, previous /*null when async*/) {
current.body = current.body.replace('mailto:itaddress@', 'mailto:hraddress@');
})(current, previous);
This works great, but only changes the first instance it finds, so the 'Approve' link, but it doesn't carry on to replace the 'Reject' link also with the new email.
Anyone know how I can have this check for ALL matches of the text and replace?
Thanks
Carl.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2018 04:23 PM
Hi All,
Found the answer, quite simple really, just needed to surround the original string with some slashes and a g to make it look globally, see below for updated script:
(function executeRule(current, previous /*null when async*/) {
current.body = current.body.replace(/mailto:itaddress@/g, 'mailto:hraddress@');
})(current, previous);
This now works a treat!
Hope it helps someone else
Cheers
Carl.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-27-2018 04:23 PM
Hi All,
Found the answer, quite simple really, just needed to surround the original string with some slashes and a g to make it look globally, see below for updated script:
(function executeRule(current, previous /*null when async*/) {
current.body = current.body.replace(/mailto:itaddress@/g, 'mailto:hraddress@');
})(current, previous);
This now works a treat!
Hope it helps someone else
Cheers
Carl.