- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 08:44 PM
Hi all,
I have a multiple choice variable named dual_monitor on a catalog item. It has two values yes and no. Also, It is part of a variable set. Once the user submits the order an event is fired which will send email notification to the approver to approve the requested item. How do I pass this variable and its value in the notification. I tried various combinations but unable to refer it. Below is email content. Also requested for field appears blank in the notification. Any suggestions?
.
Thanks & Regards,
Akriti
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2016 01:49 AM
I had a small typo. Instead of current.ref_sc_req_item.sysapproval.variables.<variable_name>, try
current.sysapproval.ref_sc_req_item.variables.<variable_name>
The "type casting" comes after, not before. By using "ref_sc_req_item", you are type casting sysapproval reference which is of type task. Using this syntax you can get not just the variables, but any other fields that are specific to the record that is type casted.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 09:35 PM
Here you go use this in the mail script to print all the variables
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.getValue('sysapproval'));
set.load();
var vs = set.getFlatQuestions();
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getLabel() != '') {
template.print(' ' + vs.get(i).getLabel() + " = " + vs.get(i).getDisplayValue() + "\n");
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 10:11 PM
You need to dotwalk from sysapproval_approver table from that.
I'm assuming your using a catalog item so that would be in sc_req_item.
try: ${current.document_id.variables.variablename}
Thanks,
Tadz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 09:52 PM
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
if(gr.next())
{
template.print(gr.variables.var_country); //change the variable name as per your need.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 10:23 PM
Hello,
I have a very similar notification. Please refer to the screen shot.
Refer to the highlighted part to know how to use requested_for in the notification mail. Since requested_for field comes from request table so we need to dot walk.
Regarding your multiple choice variable value to appear in the mail, you need to glide it as "Kalaiarasan P" has mentioned in a mail script and then use the name of that mail script in your this notification body.
Please let us know if you face any difficulties.
Thanks,
Arnab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2016 10:29 PM
Akriti,
You need to refer to the parent record if your driving table is sysapproval_approver. You need evaluate it as sysapproval_approver table dont have sc_request, sc_req_item related fields. Something similar to this code snippet will help you:
var parentTable = current.source_table;//current is pointing to sysapproval_approver table. So we need to get table on which this approval is acting.
if (parentTable == "sc_req_item") {//I am assuming you have approvals on sc_req_item table. Adjust accordingly
var parentGr = new GlideRecord(parentTable);
if (parentGr.get(current.sysapproval)){
var req_for = parentGr.requested_for;
var myVariable = parentGr.variables.<variable_name>;
}
}
Essentially, the variables are available on sc_req_item or sc_task. So, we need to get that record and access variables.
"Requested for" is available on sc_request table. So we need to dot-walk from sc_req_item to get that value.