- 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-11-2017 07:35 AM
You will need to use Mail Scripts i.e. Scripting for email notifications
Take a look at the examples which should assist you - Example scripting for email notifications
You essentially need to query the Change Request and then use the script to "print" out the required information.
The mail script can then be called from within the Notification like so...${mail_script:script name}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 07:42 AM
Thanks for your reply -- I have zero knowledge of scripting but I'll see what I can do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 08:13 AM
Hi David,
I haven't tested this but should work to display the Change Request Start date and End date fields as an example.
<mail_script>
if(sysapproval.sys_class_name == 'change_request'){
var changeRequest = new GlideRecord('change_request');
changeRequest.get(sysapproval.sys_id);
template.print(changeRequest.start_date);
template.print(changeRequest.end_date);
}
</mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 09:17 AM
Thank you, I will try this and see how I go - these are the fields I wish to bring across into the template from the change_request table into the template which is based on the sysapproval_approver table.
Comments and Work notes:
${comments_and_work_notes}
Planning:
Justification: ${justification}
Implementation plan: ${implementation_plan}
Risk and impact analysis: ${risk_impact_analysis}
Backout plan: ${backout_plan}
Test plan: ${test_plan}
Additional Details:
All Sites Affected: ${u_all_sites_affected}
Sites Affected: ${u_sites_affected}
Environment: ${u_environment}
What tests have been carried out prior to implementation?: ${u_tests_prior_implementation}
Are there any dependencies on other changes?: ${u_change_other_dependent}
Is the change focused on perimeter/DMZ based services?: ${u_change_focused}
Is the activity focused on the installation of a new appliance/service?: ${u_change_appliance_service}
Is there significant functional change in an existing appliance/service?: ${u_change_existing_service}
Communication Plan: ${u_communication_plan}
Is the request related to an incident?: ${u_related_incident}
Why is this an emergency change?: ${u_emergency_change_reason}