- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 08:22 AM
Hi Community,
I am facing weird issue in the notification, i have righten the email script for dynamic variables should be displayed from the requested item from the request table, for the lable we are getting undefined in the email and also i want to hide the yes/no variable from the email which has not question for that. .
could any one please help me where i am doing the wrong.
script:
(function runMailScript(current, template, email, email_action, event) {
template.print('<p style="font-size:16px; color:#000000; font-family:arial">');
template.print("<b>REQUEST ITEM SUMMARY:</b>");
//template.print("<b>Catalog Item Name:</b>");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("request", current.sys_id);
gr.query();
while (gr.next()) {
template.print('<br>'+"\n");
// template.print(gr.stage.getDisplayValue() + '<br>' + "\n");
// Get Owned Variables for Requested Item and sort by Order
var ownvar = new GlideRecord('sc_item_option_mtom');
ownvar.addQuery('request_item.number', gr.number);
ownvar.addQuery('sc_item_option.value', '!=', '');
var removefalse=ownvar.addQuery('sc_item_option.value','!=',false);
removefalse.addOrCondition('sc_item_option.value','!=',false);
ownvar.orderBy('sc_item_option.order');
ownvar.query();
while (ownvar.next()) {
var field = ownvar.sc_item_option.item_option_new;
var fieldValue = ownvar.sc_item_option.item_option_new.name;
template.print('<b>' + field.getDisplayValue() +": "+ '</b>' );
template.print(gr.variables[fieldValue].getDisplayValue()+'<br>');
}template.print('</p>');
}
})(current, template, email, email_action, event);
i would appriciate for the quick response.
Thanks in advance,
Shrinivasprasad
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 09:17 AM
What's the datatype of undefined field type?
You can also use below script to read RITM variable values
var scReqItem = new GlideRecord("sc_req_item");
scReqItem.addQuery("sys_id", current.sysapproval.toString());
scReqItem.query();
while (scReqItem.next()) {
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery("request_item", current.sysapproval.toString());
varown.orderBy("sc_item_option.order");
varown.query();
while (varown.next()) {
var visible = varown.sc_item_option.item_option_new.visible_summary;
var question = GlideappAbstractChoiceListQuestion.getQuestion(varown.sc_item_option.item_option_new);
question.setValue(varown.sc_item_option.value);
if (question.getLabel() != "" && question.getDisplayValue() != "" && visible == true) {
if (question.getType() == 20 || question.getType() == 19)
continue;
template.space(2);
template.print(' ' + question.getLabel() + " = " + question.getDisplayValue() + "\n" + "<br />");
}
}
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 10:41 AM
Thanks Sachin it is working now