It there a way to use \${event.parm#} as a value inside email script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2008 11:02 AM
I would like to have a business rule create an event and pass parameters to an email message and then use one of the parameter values in an email script query. Is it possible to use a parameter inside an email script? When the email is generated I see the parameter outside the script but so far I have not been able to find a way to use it as a value within the script portion of the message body.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2008 11:48 AM
Hi Mike
To my knowledge you can't directly access the "event.parm1/2" values within the tags. I'd imagine there will be a way in the future (or now? feel free to chime in anyone if there currently is!).
There is a way around this however...
Review this script, it should do what you're looking for - basically it queries the sysevent table for the last event entered (matching your criteria) and pulls the values from there:
<mail_script>
// Use these vars to store the parm values
//
var strParm1 = new String();
var strParm2 = new String();
// Query the sysevent table to get the event record that just kicked off
//
var objEvent = new GlideRecord('sysevent');
objEvent.addQuery('name', 'incident.inserted'); // this is the event we are looking for
objEvent.addQuery('instance', current.sys_id); // this is the sys id of the record we are working off of - i.e. the incident sys id
objEvent.orderByDesc('processed'); // need to order by desc so we get the latest instance of this event
objEvent.query();
while (objEvent.next())
{
strParm1 = objEvent.parm1;
strParm2 = objEvent.parm2;
break; // break out of the loop, we just want the latest event
}
// Here are your values in action, use as needed
//
template.print('<br>Event Parm 1: ' + strParm1);
template.print('<br>Event Parm 2: ' + strParm2);
</mail_script>
Late,
Gabe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 07:58 AM
Just came here to Thank you for how well this solution works!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2024 02:50 PM - edited ‎06-06-2024 02:51 PM
Just as an FYI, you can now directly access event parameters in the message without resorting to a script. You can just call ${event.parm1} and ${event.parm2}
The above answer was given in 2008, so it's a little out of date.
Can likely call other events fields as well, though I haven't tried it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2008 02:43 AM
Thanks for the reply Gabe. That is a very interesting approach. I had to take a different approach to accomplish what was needed but your recommendation does look interesting. The way I got around this was to run the query to pull the needed data in the business rule that triggers the event. As the information was returned in the query, I appended it to a variable to create the information to be displayed in the email message. This variable was passed to the email message as one of the two parameters and the parameter was added to the body of the email message. As soon as I can finish a hot item I am working on now, I want to give your recommendation a try. I did open a HI ticket and you cannot do what I was trying at this time but they were going to submit it as an enhancement request. One thing I do like is there is usually more than one way to accomplish something and it is ideas like your recommendation here that opens new ways to look at something. Thanks for the information.