how to call ritm variables in email notification

Renu9
Tera Contributor

Hi All,

I am having a requirement to call variables details in notification when we are sending it to requester.

Please let me know how I can call the variables in notification.

 

Sample:

Hi <requested for>

Based on selection, these are the below details that are selected:

<calculated list>

 

Regards,

Support Team

 

The variables are :

1.is_monitor_required?

2.is_keyboard_required?

3.is_mouse_required?

 

 

7 REPLIES 7

Dhananjay Pawar
Kilo Sage

Hi,

You can write the Email Script to fetch the variables from RITM and same Email Script you can call from notification.

 

Thanks,

Dhananjay.

Renu9
Tera Contributor

Hi @Dhananjay Pawar 

Could you please help me here how I can fetch variables

 

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

    var a = new GlideRecord('sc_req_item');
    a.addQuery('cat_item', 'On Site Worker');
    a.addQuery('sys_id', current.sys_id);
    a.query();
    while (a.next()) {
        if(......)
    }

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

Sohail Khilji
Kilo Patron
Kilo Patron

HI @Renu9 ,

 

Create a notification script and include it in your email, here is a notification script i created  a while back to include all non empty variables form a ritm in an email

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

    template.print('Variables: <br/>');

    var variables = current.variables.getElements();
    for (var i = 0; i < variables.length; i++) {
        var question = variables[i].getQuestion();
        var label = question.getLabel();
        var value = question.getDisplayValue();
        if (value != '') {
            template.space(4);
            template.print('  ' + label + " = " + value + "<br/>");
        }
    }

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

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji ,

 

Thanks, but I don't want all the variables in the RITM to be displayed.

I only want 5 from 10 variables. How can I get display them.