How to include priority, state value and worknotes changes in email body when an incident is updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
I want to send an email notification when priority, state or worknotes are updated and include the update details like current and previous values for priority / state when updated. How can this be achieved.
can this is done using a single notification?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Greetings @apurvab. I believe this can be achieved. The best out of the box solution that has access to both the current and previous values is a Business Rule. Additionally, the Business Rule allows you to trigger its logic based on the conditions you have provided.
Within the Business Rule, I can think of two options you have to trigger a Notification. I'll include both options below at a high-level. Feel free to choose whichever option you feel most comfortable with.
Option #1: Business Rule -> Fire Event -> Triggers Notification -> E-mail Script
With this option, you will configure your Business Rule by checking the Advanced checkbox which will grant you access to the Advanced tab. Within the Advanced tab, you will declare individual variables for the "current" and "previous" values of the desired fields. For work notes, you will only be capturing the last work notes entered.
var cp = current.priority;
var pp = previous.priority;
var cs = current.state;
var ps = previous.state;
var wn = current.work_notes.getJournalEntry(1);
Once you have the Business Rule configured as such, you can take advantage of the GlideSystem Event Queue method (link). With the .eventQueue method, you have the option to pass in two parameters which can be used in your Notification. In order to use the .eventQueue method you will need to create/register an Event record in your system in addition to configuring a Notification record that is triggered from an Event. Since you will be passing in more than two parameters through your Event, you will need to build an Object payload of sorts that contains all the field values. From within the Notification, you can then parse out the individual field values to display as you wish. This is just a high-level overview of this option and there is better documentation out there from others who have achieved this.
Option #2: Business Rules -> Subflow -> E-mail
With this option, you will configure your Business Rule by checking the Advanced checkbox which will grant you access to the Advanced tab. Within the Advanced tab, you will be calling a Subflow that you will build in Flow Designer. This Subflow can have 5 inputs/parameters that match the 5 field values you are wanting to track. Once you have configured your Subflow's inputs, you can use the Flow action "Send email" (link). Within the "Send email" step, you can simply drag-and-drop (no coding) the input data pills into the body of your e-mail Notification. Once the Subflow has been built, what's really nice is that Flow Designer will create a code snippet for you including a try/catch block. To get to this code within Flow Designer, go to the "More actions menu" (three horizontal dots) and select "Create code snippet". Once you have this copied to your clipboard, you can simply go back to your Business Rule and paste this code snippet into the Script field. This is as close to a no-code solution as you can get.
I hope this information helps and, as always, interested in hearing feedback from others or different solutions.
