- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 07:22 AM
Hello,
How would I pull a field through from one table into a notification template or email based on another table?
I'm trying to pull through the details of a Change Request (change_request table) and put them in an approval email template (sysapproval_approver table), and I'm not sure what the syntax would be to do this, I've tried various variations on ${table name.field name} but nothing seems to be working.
Any ideas?
Solved! Go to Solution.
- Labels:
-
Change Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 06:25 AM
Hi David,
Here you go, use the below. I've verified it works
var gr = new GlideRecord("change_request");
gr.get(current.document_id);
template.print("Start Date:" + gr.start_date + '<BR>');
template.print("End Date:" + gr.end_date);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 03:31 AM
Hi Pritam,
Thank you for your help yesterday, I created this short script, but it doesn't seem to be pulling in any details.
The script is as follows.....
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
if(sysapproval.sys_class_name == 'change_request'){
var changeRequest = new GlideRecord('change_request');
changeRequest.get(sysapproval.sys_id);
template.print("Start Date:" + change_request.start_date);
template.print(change_request.end_date);
}
})(current, template, email, email_action, event);
.... and I call it using the line ${mail_script:DR_get_change_details} in the template, but when I run my change process that generates the email based on this template, the section where the output from the script should be is blank when it needs to pull the details from the Change Request record that it relates to.
Do you know why it might not be working?
Thank you again for your help yesterday.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 05:40 AM
Hi David,
I noticed some typo's in your code... please try the below:
if(sysapproval.sys_class_name == 'change_request'){
var changeRequest = new GlideRecord('change_request');
changeRequest.get(sysapproval.sys_id);
template.print("Start Date: " + changeRequest.start_date);
template.print("End Date: " + changeRequest.end_date);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 05:56 AM
Hi there - thanks for this, I've made the change using your script but but I'm still not seeing any details of the change pulled through I'm afraid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 06:25 AM
Hi David,
Here you go, use the below. I've verified it works
var gr = new GlideRecord("change_request");
gr.get(current.document_id);
template.print("Start Date:" + gr.start_date + '<BR>');
template.print("End Date:" + gr.end_date);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 06:57 AM
Perfect! That works fine - I will add the other fields I want to pull through to that script and will confirm that all is well.
Thank you so much for all your help!