- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Developed by top engineers, the email notification is robust and elegant, a clean-line construction released from the late 2011 with top specifications. Email notifications are now mature and reliable. It is characterised by the easy-to-use interface. Email notifications are used to notify users by email, SMS text message, or push notifications of events that concern them. On the conditions, you can use most elements on the tables without the need for scripting. Wishful thinking would be to be able to use the catalog variables as we can use them on the searches. However, if you need to create email notifications and use service catalog variables on the conditions you will need to script them. Wishful thinking is one thing, and reality another.
Email notifications can be triggered from tables that contains variables like sc_req_item and sc_task tables. Whilst the searches on the table allows you to search on the variables and the request item shows the variables, the actual variables data is stored in different form. For that reason, email conditions will simply ignore the variables conditions. This is tricky to spot.
Create a notification on sc_req_item that uses the advanced conditions
For this example, I will show you how to create a notification on sc_req_item (also applies to sc_task) that uses the advanced conditions to filter on the variables. I have used a "Standard Laptop" Service Catalog and I created a notification that triggers when "Adobe Acrobat" is selected.
Creating the email notification with variables
When creating an email notification, use the 'Advanced condition' to match the variables by scripting. Use current.variables.<name of the variable> to retrieve the value, and getDisplayValue() to retrieve the display value of it. Alternatively, use current.variables["name of the variable"]
Below is an example of a notification that will trigger when the variables "acrobat" is set to "true" (checked).
Here is the advanced condition used on the example:
var v=current.variables.acrobat;
answer=v?"true"==v.getDisplayValue():!1;
The code will return answer = true if the acrobat is selected ON (checked).
Use current.variables.<name of the variable> to retrieve the value, and getDisplayValue() to retrieve the display value of it. Alternatively, use current.variables["name of the variable"]
To validate the email notification, I have created a new catalog request for a Standard Laptop.
Once you have submitted an item, the order status will show the request items. In this case. my Lenovo - Carbon x1 is in the beginning stages of the request.
When you review the request item and the variables, it shows as follows:
On the example provided, as "Adobe Acrobat" is selected on the "Standard Laptop" request item, the notification will be sent because the condition "current.variables.acrobat.getDisplayValue()" is true, and the condition Item = "Standard Laptop" is true.
How to manipulate the variables
You would like to print or manipulate the catalog variables when the data passed to the catalog items are required. To validate the information on the variables, I have created an email script to print all the variables available values. For that, I will loop on the variables array.
The email script contains a loop on the variables (array) on the current record as follow:
Here is the text on the script
// function (current, template, email, email_action, event)
(function (c, b, a, d, e) {
b.print("<UL>");
for (key in c.variables) a = c.variables[key], "" != a.getGlideObject()
.getQuestion()
.getLabel() && b.print("<LI>variable name: " + key + " (" +
a.getGlideObject()
.getQuestion()
.getLabel() + ") = " + a.getDisplayValue() + "</LI>");
b.print("</UL>")
})(current, template, email, email_action, event);
Use "for (key in current.variables) then, variable_value = current.variables[key] to loop though the variables.
Here is one example of the email generated:
Whilst not natively supported, service catalog variables can be used in and out with the help of scripting. Who knows, variables may back on the normal conditions in the near future (cross fingers). This could be very useful if you need to generate different notifications based on the answers provided on a catalog item.
I have tested this example using Helsinki, with Google Chrome as the browser.
More information can be found here:
- Email Resources Page (KB0540674)
- Adding cat item variables to email notification
- Incoming email classified as reply to 'null' via watermark
- Two watermarks in incoming Email messages
- 3 steps to determine if and why the event processor is unable to start
- Diagnosing and remedying stuck event processes
- Docs: Additional email properties
- Docs: Available system properties
- Docs: Create an email notification
- Docs: Notification examples
- Docs: Notifications
- Docs: Scripting for email notifications
- Troubleshooting email notifications - Send to the Event Creator
- Troubleshooting Outbound Email (KB0521382)
- Troubleshooting stuck event process (KB0547784)
- Verifying the recipient has an email address (KB0528669)
- Verifying the recipient's email address is properly formatted (KB0528671)
- Speed up your email delivery by validating recipients
- My other blogs
- 8,788 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.