- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2023 11:50 PM
The change request has a related list table Worklog, which will capture the cancel reason for the change in "Short Description"
The value of short description should be displayed in the email notification for change.
I have tried using a Notification Email script and calling the script in email body.
But my script is not working as expected.
Can someone please let me know how to fix this..
Notification Email Scripts
-------------
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = GlideRecord('u_work_log');
gr.addQuery('u_work_log', current.sys_id);
gr.query();
while(gr.next())
{
gs.getDisplayValueFor(current.getTableName(), current.getValue('string'),'short_description');
}
//template.print(gr.u_entry_log);
//template.print(gr.getDisplayValue('u_entry_log'));
template.print(gr.short_description);
//template.print(gr.getDisplayValue('short_description'));
})(current, template, email, email_action, event);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 07:34 AM
You won't get the short description of work log record using u_work_log field.
You need a reference field which refers to the parent ticket which your change record
There is a field-'parent' on work log table as per your screenshot.
So we can use it to get the short descript-Please update your code as below
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var work_log_description ='';
var gr = GlideRecord('u_work_log');
gr.addQuery('parent', current.sys_id);//this parent is the name of Parent field on worklog table-as per your screenshot ,please check Parent field's name and update it if it is not correct
gr.query();
if(gr.next())
{
work_log_description = gr.getValue('short_description');//please check whether short description name is correct or not on worklog table
}
//template.print(gr.u_entry_log);
//template.print(gr.getDisplayValue('u_entry_log'));
template.print(work_log_description);
//template.print(gr.getDisplayValue('short_description'));
})(current, template, email, email_action, event);
Syntax to call this email script in your notification as below-
${mail_script: email_script_name}
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact
Thanks,
Manjusha Bangale

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2023 11:57 PM
Seems, worklog is a custom table. If so, can you replace
gr.addQuery('u_work_log', current.sys_id);
with
gr.addQuery('u_parent', current.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 05:15 AM
Hi Jaspal,
I tried to change to parent but still not working, actually worklog is a custom table, extends from task table.
please suggest if any things needs to be looked at
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2023 11:59 PM
u_work_log field refers to the change record ,if yes your code is ok ,just use if instead of while.
use gs.info() method to check short description values
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 05:17 AM
Hi Manjusha,
Thankyou for suggesting, but no its not working still. can you please help with the code, as worklog being a custom table extending task table.
Short Description filed value is not retrieved in email