- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2009 02:40 PM
I'm using an email notification to send out information regarding approvals on RITM's. The information I want to send will contain the variable information from the item that was ordered.
I stole this script from another email notification:
template.print("Summary of Requested item:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.quantity + " X " + gr.cat_item.getDisplayValue() + "\n");
template.print(" Options:\n");
for (key in gr.variables) {
var v = gr.variables[key];
if(v.getGlideObject().getQuestion().getLabel() != '' && v.getDisplayValue() != '') {
template.space(4);
template.print(' ' + v.getGlideObject().getQuestion().getLabel() + " = " + v.getDisplayValue() + "\n");
}
}
}
My only issue is that the variables don't display in the proper order. You would think this would be an easy thing to accomplish, but I've been stuck for awhile. Any ideas?
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2010 06:31 AM
Yes, you can put a mail script right into the message. I have this setup on an approval request, here's the details:
table: sysapproval_approver
event: approval.inserted
and then I have a condition on the notification so that it only sends out for RITMs:
Approval for.Number "starts with" RITM
And finally here is my mail script inside the message of the email (this looks a little different than the one I posted, it helped me get the variables in order):
<mail_script>
template.print("Summary of Requested item:\n");
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", current.sysapproval);
gr.query();
while(gr.next()) {
template.print(gr.number + ": " + gr.quantity + " X " + gr.cat_item.getDisplayValue() + "\n");
template.print(" Options:\n");
var varown = new GlideRecord('sc_item_option_mtom');
varown.addQuery("request_item", current.sysapproval);
varown.query();
while (varown.next()){
var visible = varown.sc_item_option.item_option_new.visible_summary;
var question = Packages.com.glideapp.questionset.Question.getQuestion(varown.sc_item_option.item_option_new);
question.setValue(varown.sc_item_option.value);
if (question.getLabel() != "" && question.getDisplayValue() != "" && visible == true){
template.space(4);
template.print(' ' + question.getLabel() + " = " + question.getDisplayValue() + "\n");
}
}
}
</mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2013 06:58 AM
Hi Twl,
I was trying to do the same thing, but was not sucessfully.
Here's another thread Capturing the Values in the Variable Editor into an Email Notification , maybe it might work for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2013 03:56 PM
I believe this should be the correct syntax of the end of the code in the initial post based on a similar script I got to work (but this is still Aspen!):
...
template.print(" Options:\n");
for (key in gr.variables) {
var v = gr.variables[key];
if(v.getGlideObject().getQuestion().getLabel() != '' && v.getGlideObject().getValue() != '') {
template.space(4);
template.print(' ' + v.getGlideObject().getQuestion().getLabel() + " = " + v.getGlideObject().getValue() + "\n");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2015 05:38 AM
Hi All,
Below is the UI Macro we are using to print the Variables in the sys approver table:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<tr>
<td class="label_left" width="100%">
<label style="margin-left: 10px"> ${gs.getMessage('Summary of Item being approved')}
<g:label_spacing/> </label>
</td>
</tr>
<g:evaluate var="jvar_ni" expression="
var sc_req_item = ${ref}.sysapproval;
"/>
<tr>
<td width="100%">
<table width="100%">
<tr>
<td class="label_left" width="150px">
<label style="margin-left: 10px">${gs.getMessage('Number')}: </label>
</td>
<td>
${sc_req_item.number}
</td>
</tr>
<tr>
<td class="label_left" width="150px">
<label style="margin-left: 10px">${gs.getMessage('Item')}:</label>
</td>
<td>
${sc_req_item.cat_item.name}
</td>
</tr>
<tr>
<td class="label_left" width="200px">
<label style="margin-left: 10px">${gs.getMessage('Request Number')}:</label>
</td>
<td> ${sc_req_item.request.number.getDisplayValue()}
<input style="visibility: hidden" NAME="make_spacing_ok"></input> </td>
</tr>
<tr>
<td class="label_left" width="200px">
<label style="margin-left: 10px">${gs.getMessage('Requested for')}:</label>
</td>
<td>
${sc_req_item.request.requested_for.getDisplayValue()}
</td>
</tr>
<tr>
<td class="label_left" width="200px">
<label style="margin-left: 10px">${gs.getMessage('Company')}:</label>
</td>
<td>
${sc_req_item.company.getDisplayValue()}
</td>
</tr>
<tr>
<td class="label_left" width="200px">
<label style="margin-left: 10px">${gs.getMessage('Location')}:</label>
</td>
<td>
${sc_req_item.request.location.getDisplayValue()}
</td>
</tr>
<tr>
<td class="label_left" width="200px">
<label style="margin-left: 10px">${gs.getMessage('Due Date')}:</label>
</td>
<td>
${sc_req_item.due_date.getDisplayValue()}
</td>
</tr>
<tr>
<td class="label_left" width="150px">
<label style="margin-left: 10px">${gs.getMessage('Quantity')}:</label>
</td>
<td>
<g:evaluate var="ni" expression="
var totalq = sc_req_item.quantity.toString();
if (totalq != '') {
totalq = parseFloat(totalq);
totalq = totalq.toFixed(2);
}
"/>
${totalq}
</td>
</tr>
</table>
</td>
</tr>
<j:set var="jvar_line_num" value="0" />
<tr>
<td width="100%">
<table width="100%">
<tr>
<td class="label_left" width="200px">
<label style="margin-Left: 10px">${gs.getMessage('Variables')}:</label>
</td>
</tr>
<j:set var="jvar_line_color" value="odd"/>
<j:set var="jvar_line_num" value="${jvar_line_num + 1}"/>
<j:if test="${jvar_line_num % 2 == 0}">
<j:set var="jvar_line_color" value="even"/>
</j:if>
<g:evaluate var="ni" expression="
var smart_description = sc_req_item.cat_item.short_description;
if (smart_description == null || smart_description == '' || smart_description == 'undefined')
smart_description = sc_req_item.cat_item.name;
"/>
<g:evaluate var="keys">
var keys = new Array();
var currentVar;
for (key in sc_req_item.variables) {
currentVar = sc_req_item.variables[key];
if (currentVar.getDisplayValue() != 'false')
keys.push(key);
}
keys;
</g:evaluate>
<j:forEach items="${keys}" var="jvar_key">
<g:evaluate var="currentVar" expression="
var currentVar = sc_req_item.variables['${jvar_key}'];
currentVar;
"/>
<j:set var="jvar_vlabel" value="${currentVar.getGlideObject().getQuestion().getLabel()}"/>
<j:set var="jvar_vanswer" value="${currentVar.getDisplayValue()}"/>
<j:if test="${jvar_vanswer != ''}" >
<tr>
<td class="label_left" width="200px">
<label style="margin-left: 10px">${jvar_vlabel}: </label>
</td>
<td>${currentVar.getDisplayValue()}
<input style="visibility: hidden" NAME="make_spacing_ok"></input>
</td>
</tr>
</j:if>
</j:forEach>
</table>
</td>
</tr>
</j:jelly>
This is printing the variables however they are not sorted, please help to sort the variables as well
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-01-2015 11:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2015 09:30 AM
Hi Oscar,
This page is not accessible anymore.