catalog item variables in sc_task notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 09:17 AM
Hello,
I have an email notification that fires for the event 'sc_task.assigned.to.group'. It is on the sc_task table. I have a script (below) that I want to have show the variables from the catalog item that this task is attached to (the catalog task is created from the catalog item workflow). It DOES return variables, but it returns ALL of them. ALL of the variables for every single open request on the dev server is in the notification email. That makes the email a bit...long. Is there a way to only get the variables for the item that the task is related to? I first tried a glide query for the table 'sc_req_item', but got the same result. I was hoping that using sc_task would fix the issue but it didn't. Any suggestions?
<mail_script> var itemRec = new GlideRecord("sc_task"); itemRec.addQuery("task", current.sysapproval); itemRec.query(); while (itemRec.next()) { for (key in itemRec.variables) { var v = itemRec.variables[key]; if(v.getGlideObject().getQuestion().getLabel() != '') { template.space(4); template.print(' ' + v.getGlideObject().getQuestion().getLabel() + " = " + v.getDisplayValue() + "\n"); } } } </mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 10:13 AM
Yes, that shows up fine. Here is the email itself:
Short Description: Return - Equipment Request RITM0010163 for Sam Hull
Assignment group: CB - Service Desk
Click here to view Task: TASK0010348
Click here to view Requested Item: RITM0010163
Requested For:Sam Hull
Due date: 2013-12-11 11:49:47 AM CST
Description: Please retrieve the checked out equipment and close this task when it has been placed back into inventory.
Ref:MSG0173683
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 10:23 AM
Thanks, I see that works. Always something new to learn.
Are you running this email on the sc_task table, correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 10:42 AM
Yes on sc_task. But I think I figure it out with your help. I copied and pasted exactly what you had in demo007 into my notification and it still didn't work so I'm guessing that script doesn't work in Berlin, since we are still on that version. So, I simply replaced the glide record and query fields in my original script with the fields from yours and it works!
<mail_script>
var itemRec = new GlideRecord("sc_req_item");
itemRec.addQuery("sys_id",current.request_item );
itemRec.query();
while (itemRec.next()) {
for (key in itemRec.variables) {
var v = itemRec.variables[key];
if(v.getGlideObject().getQuestion().getLabel() != '') {
template.space(4);
template.print(' ' + v.getGlideObject().getQuestion().getLabel() + " = " + v.getDisplayValue() + "\n");
}
}
}
</mail_script>
Thanks so much for you help! I really appreciate it!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 11:03 AM
Great, thanks for reporting back.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2013 10:13 AM
I pasted this script directly on DEMO and it is working fine:
https://demo007.service-now.com/nav_to.do?uri=sysevent_email_action.do?sys_id=03973320c0a801020075d86be149dcbb