Conditional Email scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2010 09:34 AM
I am trying to setup our Email Notification to be based on a condition. For our Termination Request process, these are submitted on behalf of another employee and thus we wouldn't want an email notification being sent to that (soon-to-be-termed) employee.
I'd like to be able to pull the requested item name (Terminate Employee Access) and check against its value prior to having that email send. If it sees that it is set to the above value, it won't send the email.
I can't seem to find the right condition fields available on the request item level to check this. Any ideas or thoughts on a script that could pull these field?
For this type of request (Termination) there is only one catalog request item that is created if that helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2010 12:37 PM
Hi -
If you build the email notification on the sc_req_item table you do have the option of choosing the "Item" in the conditions. I would create 2 Email notifications one for all Requested Items and set the condition to (Item is not Terminated Employee), the 2nd one for the "Terminated Employees", set the condition to (Item is Terminated Employee).
Hope this gets you going in the right direction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2010 06:49 AM
That would work as well but we'd rather have the email notification initiated from the request. Do you know how I could query the catalog items requested from that level?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2010 04:10 PM
The email notification does initiate from the request. The "sc_requests_events" Business Rule triggers the notification. If you create the new email notifications just use the same event name to fire off the email notification.
Below is a sample mail script to use as a query example. You will need to do a glide record query.
<mail_script>
template.print("<p></p>Requested items:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.cat_item.getDisplayValue() + ", Stage: " + gr.stage.getDisplayValue() + "\n");
}
</mail_script>