Pulling a field through from another table into a Notification email

davidreid
Kilo Contributor

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?

1 ACCEPTED SOLUTION

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);


View solution in original post

17 REPLIES 17

Thank you again for your help Pritam, I've pulled through all the relevant information and the templates are looking good now.



Kind regards



David


Hi David,



Glad to hear it all works as intended



Feel free to mark the thread as answered.



Thanks,



Pritam


Thanks for sharing Pritman, the code works well. 
Using this example the start/end time are in GMT. How can these be modified to EST?

Also, I'm include the Risk field which returns an integer. Is there a way to return the field label instead?  Thank you in advance. 

I used the same logic to pull a variable from a table "kb_knowledge" to a notification created based on table: 'kb_feedback_task'

 

I used the following

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
 
    // Add your code here
    var gr = new GlideRecord('kb_knowledge');
gr.get(current.feedback.article);
        template.print(gr.short_description);
})(current, template, email, email_action, event);

Sharique Azim
Kilo Sage

Hi David,



If the notification is on the sysapproval table then simply   using ${sysapproval.field_name} you can print the field name.