About Email Notification Variables

shibasou
Kilo Sage

Hi guys.

 

I want to display the value obtained from the record producer in the email notification.

Is there any way?

 

Thank you.

1 ACCEPTED SOLUTION

Sainath N
Mega Sage
Mega Sage

@shibasou : There are a couple of ways to achieve this.

 

1. If you are mapping your record producer variables to fields on the target table, you can get values directly from the table fields. Ex: ${current.YOUR_FIELD_NAME}

 

2. If that's not the case, you can get the values from the "Question Answers" [question_answer] table. Below is the sample code, which you can configure in your email script and call the email script in your email notification. Ex: ${mail_script:YOUR_MAIL_SCRIPT_NAME}

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    var ql = new GlideRecord('question_answer');
    ql.addQuery('table_sys_id', current.sys_id.toString());
    ql.orderBy('order');
    ql.query();
    while (ql.next()) {
        template.print(ql.question.getDisplayValue() + ": " + ql.value.getDisplayValue() + "\n");
    }

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

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

View solution in original post

3 REPLIES 3

Sainath N
Mega Sage
Mega Sage

@shibasou : There are a couple of ways to achieve this.

 

1. If you are mapping your record producer variables to fields on the target table, you can get values directly from the table fields. Ex: ${current.YOUR_FIELD_NAME}

 

2. If that's not the case, you can get the values from the "Question Answers" [question_answer] table. Below is the sample code, which you can configure in your email script and call the email script in your email notification. Ex: ${mail_script:YOUR_MAIL_SCRIPT_NAME}

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    var ql = new GlideRecord('question_answer');
    ql.addQuery('table_sys_id', current.sys_id.toString());
    ql.orderBy('order');
    ql.query();
    while (ql.next()) {
        template.print(ql.question.getDisplayValue() + ": " + ql.value.getDisplayValue() + "\n");
    }

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

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thank you, I'll give it a try.

@shibasou Sure...

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.