variables translated in notification email

Shir Sharvit
Tera Contributor

Hey
I created a form u_support_feedback with the field u_feedback_subject - a choice type field, whose values in the field exist in two languages both Hebrew and English.
I need to add a mail script to the notification that will retrieve the values for me only when the language =he.

 

I solved the answer with glide record but it doesn't work:

ShirSharvit_0-1704029828605.png

 

(function runMailScript(current, template, email, email_action, event) {

    var gr = new GlideRecord('sys_choice');
    gr.addQuery('name', 'u_support_feedback');
    gr.addQuery('element', 'u_feedback_subject');
    gr.addQuery('value', current.u_feedback_subject);
    gr.addQuery('language', 'he');
    gr.query();

    if(gr.next()) {
        var subjectValue = gr.getValue('label');
        return subjectValue;
    }

    // If no matching record found, the function will return undefined by default
})(current, template, email, email_action, event);

)(current, template, email, email_action, event);

 

I would be happy to help what I am missing in the code so that the value from the query is returned to me in the notification

1 REPLY 1

Rene El Hamzh
Kilo Sage

Hi @Shir Sharvit,

 

instead of returning the value, you need to use template.print() to print it to the email body. 

 

(function runMailScript(current, template, email, email_action, event) {

    var gr = new GlideRecord('sys_choice');
    gr.addQuery('name', 'u_support_feedback');
    gr.addQuery('element', 'u_feedback_subject');
    gr.addQuery('value', current.u_feedback_subject);
    gr.addQuery('language', 'he');
    gr.query();

    if(gr.next()) {
        var subjectValue = gr.getValue('label');
        template.print(subjectValue);
    }

    // If no matching record found, the function will return undefined by default
})(current, template, email, email_action, event);

 

Best regards,

Rene