- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2019 11:58 AM
I have a requirement to send a notification to a manager 10 days before their employee will term:
I wrote the following script for a Scheduled Script Execution to run everyday:
var gdt = new GlideDateTime();
gdt.addDays(10);
var td = new GlideRecord('sys_user');
td.addQuery('u_termination_date', gdt);
td.query();
while (td.next()) {
gs.eventQueue ("tenday.term.notification", current, td.manager.email, td.name);
}
This registers an event, which inturn kicks off the notification. There a 3 pieces of information that I need from the user record, the manager's email, that is in Parm1, the user's name, in Parm2, but the third one, termination date I can't populate.
The notification is built off of the sys_user table, but because the notification is triggered from an event and not an actual change to the table, it's not identifying the correct record so ${u_termination_date} is always blank.
Any ideas on how to direct the notification to the correct user record to pull the termination date?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2019 12:08 PM
Hi Chad,
Add all your parameters to a JSON object and pass it in parameter 1:
Add value/pairs to variable in a JSON object.
var details = {"manager": td.manager.email, "name": td.name, "termination_date" : your_termination_field};
Refer to object in Email Script:
//extract details from JSON object
var firstName = event.parm1.manager.toString();
var lastName = event.parm1.name.toString();
var address = event.parm1.termination_date.toString();
//print results
template.print(manager);
template.print(name);
template.print(termination_date);
Brent
P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-28-2019 12:08 PM
As the script is on schedule script execution. There are couple of changes that needs to be done
var gdt = new GlideDateTime();
gdt.addDays(10);
var td = new GlideRecord('sys_user');
td.addQuery('u_termination_date', gdt.getDate());
td.query();
while (td.next()) {
gs.eventQueue ("tenday.term.notification", td, td.manager.email, td.name);
}
To pass more values as parameters, define an object and pass it to parameter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2019 10:21 AM
Hi there,
One more way to achive what you mentioned is:
> Join the 2 or more parameters using special character such as "~". Eg: var param_one= manageremai+"~" + username ;
>Then split it in the email script using split("~");
>send the param 2 as termination date.
By using this you can send as many parameters you want then split it in an array.
Hope this helps you.
Regards,
Snehal Madakatti