- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 01:53 PM
I would like to make it so that I can assign custom headers and footers to email notifications. Ideally what I would like to do is add a reference field for the header and footer on the email notification form and then when the email gets sent it can attach the header and footer for me. What would be the best way to go about this? Is it even possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 09:30 AM
Figured this out. For anyone that is curious, this is how I did it:
- Created table for headers and footers
- Added header and footer reference fields to the email notification form
- Created a business rule in the sys_email table that runs before insert that did the following:
- Emails contain a reference to the record used to produce them(the instance field), so I used this to query the sysevent table.
- Query the sysevent table for the most recent event that refers to the same instance and then get the name of the event. You must filter out the user.view and glide.heartbeat events. (kind of sketchy if there are very high volumes of events, but it was the best I could think of)
- Use the event name to query the sysevent_email_action (email notification) table.
- Once you have the right notification record, you can use the header and footer reference fields to get their HTML.
- Add the header HTML to the beginning of the body. Add the footer HTML to the bottom of the body.
Caveats to this method:
- It assumes a 1:1 ratio of email events to notifications. So if you have more than one notification tied to an event, you will run into trouble.
- Won't work for emails that are sent when records are inserted or updated. Most emails I send are through events anyways so that didn't really matter to me. I added a UI Policy to hide the header and footer fields unless the email is sent by an event.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 01:56 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 02:18 PM
Keep me posted on this to let me know how it goes Breyton!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 02:21 PM
Thanks for the quick reply Chuck! This is very close to what I want to do. However, if possible I would like to avoid having to add that snippet to every email notification that I have on my instance. Before I started working on our instance, someone added a business rule to the email table that essentially adds a header and footer to the html before sending the email. Ideally, I would like to be able to do something like that business rule so I don't have to add code to every email notification. The hardest part so far has been trying to figure out how an email notification gets mapped to an actual email when an event gets raised. Would you have any insight on this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2016 02:24 PM
Hi Breyton,
Thanks for the feedback. My thing was designed to work with many different headers/footers, departments etc. Legal wants X, Sales wants Y, IT wants A and B so I made it flexible.
You could certainly do something similar with a business rule, but it would be more obfuscated and hard coded which means it is harder to maintain in the future. This is a little pain the first time, then changes to the headers can be done in production if needed because it's just data!