Show checkbox value instead of true/false

gnunez
Kilo Guru

Hello all,

I am trying to find a way to display the checkbox value instead of "true" "false" on the email notification "Request Opened on behalf". We would like for the requester to receive a list of the software requested in the email, but the way the values are showing now are just true, false. 

I looked through other threads and some say email script but I have no idea where to get started on this because I don't know much about scripting, but can anyone assist with this? Or point me to the right direction?

E.g. Software list: microsoft office, adobe creative cloud, dreamweaver, etc. 

If user selects office but not the other ones then the email notification look something like this:

Number: RITM4242

Requested for: Jane Doe

Software requested: Microsoft Office

My email script below:

 

 

 

Thanks in advance,

Grace

1 ACCEPTED SOLUTION

gnunez
Kilo Guru

This was my solution:

1. Create a notification email script (e.g. checkbox) and list out your checkbox values accordingly:

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

if(current.variables.checkbox_value=='true'){
template.print("Checkbox Name," + ' ' );
}
if(current.variables.checkbox_value2=='true'){
template.print("Checkbox Name2," + ' ');
}

..........

template.print('</p>');

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

 

2. Create an email notification and add the email script to an email template
e.g.  Add the following in message HTML = ${mail_script:NAMEHERE}

View solution in original post

6 REPLIES 6

Nitin_NOW
Tera Guru

You can create a notification email script and use it in the email notification body. Please create email script something like below.

var url='';
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while(gr.next()) {

url = "https://"+ gs.getProperty('instance_name') +".service-now.com/sp?id=form&view=ess&table=sc_req_item&sys_id="+gr.sys_id;
template.print('<a href='+url+'>' + gr.number +' - ' + gr.cat_item.name + '</a><br/>' + "\n");

}

Please copy and paste the code as it is, it should work without any changes (UNLESS YOU HAVE ANY CUSTOM FIELDS WHICH CAPTURE ITEM NAME).

Please hit correct based on impact of response.

Thanks!

Thanks for the response! I created the notification email script with your suggested code and replaced the instance name with ours but it didn't return anything.

When you say "unless you have any custom fields which capture item name" does that mean I should be specifying my checkbox values? 

You not replace the instance name. It is a property available in your servicenow environment and fetches the value from there. Please revert it back.

No you should not display any check box values. I mean to say about the Item field on RITM form. If you guys are using any custom field, you have to replace it with that particular, which I hardly believe it isn't the case. 

Please hit correct based on impact of response.

Thanks!

I reverted back but still the email isn't returning any value not even true/false for the checkboxes.