- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 12:26 PM
Hi,
I have requirement where you have a form (catalog item) and you have to capture the user's responses from it in an email.
To do that I have created a mail script and it is working fine for 99% of the values on the form, but for some reason it is not working for a question that is a drop down choice.
If you choose option A 3 questions come up, if you choose B 4 come up and I am not able to capture those 3 or 4 questions, though I am able to capture the value of the dropdown question itself. Below is my code and please read the comments because they explain what is happening. It seems a big wall but it is pretty redundant in the end.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
// Add your code here
var ritmSysId = current.request_item.toString();
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(ritmSysId)) {
email.addAddress("cc", ritmGr.u_requested_for.email, ritmGr.u_requested_for.name);
email.addAddress("cc", ritmGr.opened_by.email, ritmGr.opened_by.name);
email.addAddress("cc", ritmGr.u_requested_for.manager.email, ritmGr.u_requested_for.manager.name);
var orderType = ritmGr.variables.bancs_01;
if (orderType == 'add') {
email.setSubject('BANCS ACCESS - Add');
}
if (orderType == 'remove') {
email.setSubject('BANCS ACCESS - Remove');
}
if (orderType == 'amend') {
email.setSubject('BANCS ACCESS - Amend');
}
template.print("<br/>");
template.print('<table>');
//below are the questions which are common for all the choices of add, amend or remove
template.print("<tr>");
template.print("<td><left>" + "RITM Reference" + "</left></td>");
template.print("<td><left>" + ritmGr.number + "</left></td>");
template.print("</tr>");
//below are questions which are again common for all 3 order types, but they are coming from a variable set
template.print("<tr>");
template.print("<td><left>" + "Type of Request" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.bancs_01 + "</left></td>");
template.print("</tr>");
//For the below question, it is not coming from a variable set but from the variable of the catalog item. I am able to capture this in the email just fine, but unable to capture the questions following it based on the choice
template.print("<tr>");
template.print("<td><left>" + "Please select either a Virtual or Physical Diligenta RSA Token?" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.please_select_either_a_virtual_or_physical_diligenta_rsa_token + "</left></td>");
template.print("</tr>");
//The questions below are for the choices add or amend
if (orderType == 'add' || orderType == 'amend') {
template.print("<tr>");
template.print("<td><left>" + "Permanent? (Yes/No)" + "</left></td>");
template.print("<td><left>" + ritmGr.u_requested_for.u_employment_type + "</left></td>");
template.print("</tr>");
}
//The below questions are for if the order type is remove
if (orderType == 'remove') {
template.print("<tr>");
template.print("<td><left>" + "Please select if JasperSoft Access is to be removed" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.bancs_05 + "</left></td>");
template.print("</tr>");
}
//Here is what is not working at all and it is related to the question that is in the section for all the choices
if (please_select_either_a_virtual_or_physical_diligenta_rsa_token == 'Virtual Token') {
template.print("<tr>");
template.print("<td><left>" + "Please provide type of Mobile phone, (Apple or Android)?" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.please_provide_type_of_mobile_phone_apple_or_android + "</left></td>");
template.print("</tr>");
template.print("<tr>");
template.print("<td><left>" + "Please provide your Business E-mail address" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.please_provide_your_business_e_mail_address + "</left></td>");
template.print("</tr>");
template.print("<tr>");
template.print("<td><left>" + "Please provide your Personal E-mail address" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.please_provide_your_personal_e_mail_address + "</left></td>");
template.print("</tr>");
}
if (please_select_either_a_virtual_or_physical_diligenta_rsa_token == 'Physical Token') {
template.print("<tr>");
template.print("<td><left>" + "Please provide type of Mobile phone, (Apple or Android)?" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.please_provide_type_of_mobile_phone_apple_or_android + "</left></td>");
template.print("</tr>");
template.print("<tr>");
template.print("<td><left>" + "Please provide your Business E-mail address" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.please_provide_your_business_e_mail_address + "</left></td>");
template.print("</tr>");
template.print("<tr>");
template.print("<td><left>" + "Please provide your Personal E-mail address" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.please_provide_your_personal_e_mail_address + "</left></td>");
template.print("</tr>");
template.print("<tr>");
template.print("<td><left>" + "Please provide the Full Delivery Address?" + "</left></td>");
template.print("<td><left>" + ritmGr.variables.please_provide_the_full_delivery_address + "</left></td>");
template.print("</tr>");
}
template.print('</table>');
template.print("<br/>");
template.print("<br/>");
}
})(current, template, email, email_action, event);
I am unable to capture the answers which are in the last if statement. These questions pop up when you choose virtual or physical token. However the choice of virtual or physical is captured in the email. What have I done wrong?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 03:28 PM
In the if condition, you dont have the full dotwalk
ritmGr.variables.please_select_either_a_virtual_or_physical_diligenta_rsa_token
instead you have
please_select_either_a_virtual_or_physical_diligenta_rsa_token
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 01:58 PM
Is it possible a difference between the display value and the value of the variable? Is the actual value "Physical Token" or is is something like "physical_token" or 1?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 03:04 PM
No, the value is how it’s written in the code it is not that issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 03:28 PM
In the if condition, you dont have the full dotwalk
ritmGr.variables.please_select_either_a_virtual_or_physical_diligenta_rsa_token
instead you have
please_select_either_a_virtual_or_physical_diligenta_rsa_token
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2023 01:23 AM
Thanks so much! That has resolved the issue. I have marked yours as solution.