- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 04:05 AM
Hello All,
Below is the script I tried, and it is trigerring depending on 'due date' as expected with a few conditions, but I need to display a list of task numbers in notification content, but all my trails got failed in the email script. Could you please help me to get the task numbers that are already coming from the scheduled script?
How can I print task numbers through Scheduled Job parameters in the email script?
Scheduled Job Script:
var par = new GlideRecord('sn_hr_le_case');
par.addEncodedQuery('active=true^hr_service.fulfillment_type=lifecycle_event^subject_person.location.country=india^ORsubject_person.location.country=in^hr_service=0f022b791bee9410cc129759bc4bcbff^u_due_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
par.query();
while (par.next()) {
par1 = par.number;
gs.info('Parent Case Number'+"-" +par1);
gs.info('Parent Case Number count' + " - " + par.getRowCount(par1));
var arr = [];
var gr = new GlideRecord('sn_hr_core_task');
gr.addQuery("state", "!=", 3);
gr.addQuery("state", "!=", 4);
gr.addQuery("state", "!=", 7);
gr.addQuery('parent', par.sys_id);
gr.query();
while (gr.next()) {
arr.push(gr.number + "");
}
gs.eventQueue("sn_hr_le.lifecycle_event_duedates", par, arr.toString());
gs.info('count' + gr.getRowCount(arr.toString()));
}
gs.info('Due Task Number list' + arr.toString());
Output from Background scripts:
Many Thanks in Advance, Please help!!
Kind Regards,
Chandini
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 02:49 AM
Hi @bhuvana7 Please try with the below Script for printing the Task data in a tabular format:
template.print("</td></tr>");
var pin = event.parm2; // Added "=" to assign 'event.parm2' to 'pin'
var array = pin.split(","); // Changed 'pln' to 'pin' and added '='
for (var i = 0; i < array.length; i++) {
var rpa = new GlideRecord("sn_hr_core_task"); // Removed extra "("
rpa.addQuery(query); // Changed 'array[1]' to 'query'
rpa.query();
while (rpa.next()) {
template.print("<tr><td style=\"padding: 5px; border: 1px solid; border-color: grey;\">"); // Fixed HTML and added missing "\" before double quotes
template.print(rpa.number);
template.print("</td><td style=\"padding: 5px; border: 1px solid; border-color: grey;\">"); // Fixed HTML and added missing "\" before double quotes
template.print(rpa.short_description); // Changed 'rpa,' to 'rpa.'
template.print("</td><td style=\"padding: 5px; border: 1px solid; border-color: grey;\">"); // Fixed HTML and added missing "\" before double quotes
template.print(rpa.state);
template.print("</td></tr>");
}
}
Thanks & Regards,
Eswar Chappa
Mark my answer correct and Helpful if this helps you 😀
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2023 07:44 AM
Hi @bhuvana7,
First you need the email script,
In that mail script you have access to the array via
var arrNumbers = event.parm1;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 02:49 AM
Hi @bhuvana7 Please try with the below Script for printing the Task data in a tabular format:
template.print("</td></tr>");
var pin = event.parm2; // Added "=" to assign 'event.parm2' to 'pin'
var array = pin.split(","); // Changed 'pln' to 'pin' and added '='
for (var i = 0; i < array.length; i++) {
var rpa = new GlideRecord("sn_hr_core_task"); // Removed extra "("
rpa.addQuery(query); // Changed 'array[1]' to 'query'
rpa.query();
while (rpa.next()) {
template.print("<tr><td style=\"padding: 5px; border: 1px solid; border-color: grey;\">"); // Fixed HTML and added missing "\" before double quotes
template.print(rpa.number);
template.print("</td><td style=\"padding: 5px; border: 1px solid; border-color: grey;\">"); // Fixed HTML and added missing "\" before double quotes
template.print(rpa.short_description); // Changed 'rpa,' to 'rpa.'
template.print("</td><td style=\"padding: 5px; border: 1px solid; border-color: grey;\">"); // Fixed HTML and added missing "\" before double quotes
template.print(rpa.state);
template.print("</td></tr>");
}
}
Thanks & Regards,
Eswar Chappa
Mark my answer correct and Helpful if this helps you 😀
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 03:00 AM
Hi Bhuvana,
Please try sending the task numbers in JSON format and then in the email script use event.parm1 to get the JSON object and then parse the JSON object.
Best regards
Vishnu Prasad