- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2020 08:23 AM
Hi all,
I'm trying to add the email watermark to the subject in the email client template (and certain quick messages). I found this link
But I think I'm messing up the 'When'. Is it a before/ after insert/ update. I've tried all sorts of combinations, no success.
The script calls on onBefore,
And it's unclear to me if we'll see the watermark before submitting, or if it will be generated when you send.
Kind regards,
Thrishna
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2020 08:11 AM
Hi Allen,
Thanks for clarifying.
I got it to work. The watermark is not visible in the body or subject until after sending the email.
When to run: Before Insert & Update
Advanced:
-Condition: current.type.changesTo('send-ready')
-Script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sys_watermark');
var email_id = current.sys_id;
gr.addQuery('email', email_id);
gr.query();
if (gr.next())
{current.subject = current.subject + " - Ref:" + gr.number;
}
})(current, previous);
The script is basically the same as in the article I referenced above, but the function is different. I think that's what made it work today. And perhaps a good night's rest. 🙂
Thanks again. Kind regards,
Thrishna

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2020 08:27 AM
Hi,
For email client, you are unable to script anything in terms of the user seeing it themselves, on the form, in the moment. There is potential to add a business rule on the sys_email table, look for header information that would say it was sent from the email client, then perhaps script to rename the subject, but would only be seen after the email was sent from SN (so by recipient(s) and also in email log).
So you can make the BR "before", but that still means after the user submitting it, but before it's written to the server. An "after" BR, is after the user submits it AND after it was written to the server. Before BRs are usually if you are changing values on the record itself, after BRs are usually when you are using that information in the record, but making updates or doing things elsewhere.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2020 08:11 AM
Hi Allen,
Thanks for clarifying.
I got it to work. The watermark is not visible in the body or subject until after sending the email.
When to run: Before Insert & Update
Advanced:
-Condition: current.type.changesTo('send-ready')
-Script:
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sys_watermark');
var email_id = current.sys_id;
gr.addQuery('email', email_id);
gr.query();
if (gr.next())
{current.subject = current.subject + " - Ref:" + gr.number;
}
})(current, previous);
The script is basically the same as in the article I referenced above, but the function is different. I think that's what made it work today. And perhaps a good night's rest. 🙂
Thanks again. Kind regards,
Thrishna

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-22-2020 08:31 AM
Hello,
Not sure what you mean by function is different. Glad you got it resolved. I'm glad my reply was Helpful, if it was the correct answer to help lead you towards a solution, please mark as Correct.
Otherwise, yes, your own response with your own code is Correct.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!