Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Display RITM variables in Approval request OOB notification body

Ashwin Perumal1
Tera Contributor

Hello All,

I am using my OOB notification "Approval request" which creates a email when there is an approval for my RITM (catalog item). Currently I have added some messages in notification body along with that I want all my catalog item variables in my notification body  which the user has selected while submitting the request. I tried setting using email script but it was not working as expected. I am not able to see any variables in notification body. 

Can anyone help me on this email scripting..Thanks in advance...

1 ACCEPTED SOLUTION

Anirudh Pathak
Mega Sage

Hi @Ashwin Perumal1 ,

Create an email script with the below code - 

 

var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('sys_id', current.sysapproval);
    ritm.query();
    if (ritm.next()) {
        var variables = ritm.variables.getElements();
        for (var i = 0; i < variables.length; i++) {
            var question = variables[i].getQuestion();
            var label = question.getLabel();
            var value = question.getDisplayValue();


            if (label != '' && value != '') {
                template.print(label + " = " + value + "<br/>");
            }
        }
    }

 Call the email script in your notification - ${mail_script:email_script_name}

View solution in original post

4 REPLIES 4

kps sumanth
Mega Guru

Hello @Ashwin Perumal1 ,

 

Could you please share the code snippet.

Anirudh Pathak
Mega Sage

Hi @Ashwin Perumal1 ,

Create an email script with the below code - 

 

var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('sys_id', current.sysapproval);
    ritm.query();
    if (ritm.next()) {
        var variables = ritm.variables.getElements();
        for (var i = 0; i < variables.length; i++) {
            var question = variables[i].getQuestion();
            var label = question.getLabel();
            var value = question.getDisplayValue();


            if (label != '' && value != '') {
                template.print(label + " = " + value + "<br/>");
            }
        }
    }

 Call the email script in your notification - ${mail_script:email_script_name}

Thanks a lot .It worked perfectly as expected. But one thing is there any possible way we can increase the font size. I want my variables alone to be displayed in a little bigger font. Any possible way we can change the code.