- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2018 11:40 AM
My workflow creates 3 sequential tasks. As each task closes, a notification is sent. I want to include the work note value of the just closed task in the email, but I am getting inconsistent results. The work note from the first task is included in the first notification, but the 2nd and 3rd notifications are including just the work note from the 1st - although I'm getting the 2nd work note in the 2nd email sometimes.
I am using a mail script. Do I need to order the task records to get the correct work note from the latest task?
This line is in the email body:
${mail_script:zPTC_task_worknote}
This is my Email Script:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var taskRec = new GlideRecord('sc_task');
taskRec.addQuery('active', false);
taskRec.addQuery('request_item', current.sys_id);
taskRec.query();
if(taskRec.next()) {
template.print(taskRec.work_notes.getJournalEntry(1));
}
})(current, template, email, email_action, event);
Thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2018 12:47 PM
Hi Eileen,
Can you try this in email script and test.
var taskRec = new GlideRecord('sc_task');
taskRec.addQuery('active', false);
taskRec.addQuery('request_item', current.sys_id);
taskRec.orderByDesc("sys_updated_on");
taskRec.query();
if(taskRec.next()) {
template.print(taskRec.work_notes.getJournalEntry(1));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2018 11:53 AM
Hi Eileen,
Why are you writing the mail script on closure of a task.
Whichever task gets closed, just use "current.work_notes.getJpurnalEntry(1)", so it will print the work notes from the task closed recently.
Thanks,
Gaurav Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2018 12:12 PM
Thanks Gaurav, that is so much easier than how I was trying to do it. I don't know why I was using an email script - probably copying some other example. But I see that your suggestion is the best solution for maintenance.
And it was a very fast reply!
Thanks again.
Eileen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2018 12:31 PM
Gaurav,
So after testing, I'm still not getting the work notes to appear in the email message. I think I was looking at the last test I did when I thought it was working.
This is what I have now:
___________________________
and the result I get is this:
Number: RITM0023980
Opened: 2018-01-03 15:21:43 EST
Item: Network/Phone Connection Service
Work Notes:
If you have any questions or need any assistance, please call the IT Service Desk at xxxxx (subcarrier number) or xxxxx for cell phones or other non-PTC phone.
I also tried just adding the line as you specified without the ${} but that didn't work either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2018 12:47 PM
Hi Eileen,
Can you try this in email script and test.
var taskRec = new GlideRecord('sc_task');
taskRec.addQuery('active', false);
taskRec.addQuery('request_item', current.sys_id);
taskRec.orderByDesc("sys_updated_on");
taskRec.query();
if(taskRec.next()) {
template.print(taskRec.work_notes.getJournalEntry(1));
}