- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 09:37 AM
I have a request to add two items to the email notification that is configured via the sysapproval_approver table. The ask is to add the category and subcategory from the Change itself into the body of the email. Now the fields available do not seem to be helping me add those, I have tried multiple formats like current.change_request.(fieldname) and it's not working. I have looked at using the email template of change.itil.approver.role in the what it contains area but that's overkill by a lot, they don't want all of the details.
I have tried changing the table in the notification field to change_request but then the triggers don't work and can't be set up properly to key on the approvers field. Does this have to be a mail script and if so, how difficult is that to set up?
Solved! Go to Solution.
- Labels:
-
Change Management
-
Multiple Versions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 11:13 AM
This:
${mailto.script:change_email_info}
Should be:
${mail_script:change_email_info}
The mailto is something different, I should have cropped that out of my screenshot to avoid confusion. It is to create email links (like an HTML mailto link to open a new email message).
For your email script, I would use this:
var html = "";
var gr = new GlideRecord(current.source_table);
if (gr.get(current.document_id)) {
html = "<strong>Category: </strong>" + gr.u_request_type + "\n";
html += "<strong>Subcategory: </strong>" + gr.u_subcategory;
}
template.print(html);
- The "\n" is a line break.
- The gr.get should have an "if" just in case it fails. That should never happen but I always put it in just in case something very unexpected happens.
- I am assuming the gr.u_request_type is your category field.
I haven't debugged the email script but that should work. Any questions just let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 11:13 AM
This:
${mailto.script:change_email_info}
Should be:
${mail_script:change_email_info}
The mailto is something different, I should have cropped that out of my screenshot to avoid confusion. It is to create email links (like an HTML mailto link to open a new email message).
For your email script, I would use this:
var html = "";
var gr = new GlideRecord(current.source_table);
if (gr.get(current.document_id)) {
html = "<strong>Category: </strong>" + gr.u_request_type + "\n";
html += "<strong>Subcategory: </strong>" + gr.u_subcategory;
}
template.print(html);
- The "\n" is a line break.
- The gr.get should have an "if" just in case it fails. That should never happen but I always put it in just in case something very unexpected happens.
- I am assuming the gr.u_request_type is your category field.
I haven't debugged the email script but that should work. Any questions just let me know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 12:17 PM
You've nailed it. Thank you so much for the guidance. The line didn't break but that's no big deal and we can tinker with the formatting now that we have the code working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 12:25 PM