Trigger Email in Scheduled Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 12:04 PM
Hello,
I created the following script to trigger an email notification. I want to pass the list of part numbers to that email notification, how can I achieve that? I added gr as parameter, but not sure if I need to do something else.
I have a challenge where each record has a Task No associated, is it possible to in the email notification like a table to show the SCTASK Number and the Part Number next to it.
//The challege the I have records that belongs to a different task no, I want to trigger an email that contains the FG numbers associted to its respective task no.
var gr = new GlideRecord('u_udi_tracking_data');
var finished_good_numbers = [];
var task_no = [];
gr.addEncodedQuery('u_status=Yes^u_udi_flag=false'); //Search in the UDI List the records where the Status is Yes and the Flag is false
gr.query();
gs.info("length: " + gr.getRowCount());
while(gr.next()) {
finished_good_numbers.push(gr.getValue('u_new_finished_good_upn_part_number')); //Add the FG Numbers to the Array List
task_no.push(gr.getValue('u_task_no')); //Add the task no to another Array List, task no is the same SCTASK Number in Catalog Task Table
gr.setValue('u_udi_flag', true); //set UDI Flag to true
gr.update();
}
//Print the result
gs.info("Part Numbers: " + finished_good_numbers + " Task No: " + task_no);
//I want to trigger a notification that includes the FG part numbers
gs.eventQueue('UDI.EmailSME', gr);
The table can looks like this in the email notification.
Task No | Part Number |
SCTASK0080684 | 1234 |
SCTASK0080684 | 4321 |
SCTASK0080894 | 5678 |
SCTASK0080894 | 8765 |
I really appreciate any help.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2022 12:25 PM
Hello,
gr, alone, is just the record object you are passing, you have a parm1 and parm2 parameter after that, that can be used to pass information to the notification.
You would need to build the appropriate array of values to pass along to the notification and then in mail script, build a table as needed.
Example of HTML you can use: https://www.w3schools.com/html/html_tables.asp
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2022 11:38 AM
Thanks Allen, I found a way to pass a array to the event and then build the table in the email script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2022 09:47 AM
Hi,
Great work!
If my reply helped guide you Correctly, please mark that reply as Correct.
Thanks and take care! 🙂
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!