Request Item variables in Approval Summarizer

Chuck Tomasi
Tera Patron

Is it possible to utilize variables and their values in the approval summarizer screen?

This is one of my most common requests from managers. "Why do I have to cilck on another screen to see the information I am going to approve?" I'd like to put as much information on the approval screen as necessary to give them an idea of what they are approving beyond "New PC hardware" or "Folder permission request".

When I look at the object id of my "Additional Comments" variable that I use in many forms, it is something like ni.VEcdc4b6fe0a0a3c0e13cc48e36998ea41

I tried using (unsuccessfully) in the jelly code similar to how "Special Instructions" is used, like this:



<tr>
<td class="label_left" width="150px">
<label style="margin-left:10px">${ni.VEcdc4b6fe0a0a3c0e13cc48e36998ea41.sys_meta.label}: </label>
</td>
<td> ${ni.VEcdc4b6fe0a0a3c0e13cc48e36998ea41}
<g:label_spacing/> </td>
</tr>


Since each request item may have different variables, a script that loops through each set of variables would be the best so I can provide as much information to the approver without going to the request item.

5 REPLIES 5

rburgering
Kilo Contributor

You could try this UI Macro as replacement for your sc_request approval summarizer.
Rename to .xml and you can import it. It may overwrite your existing approval summarizer, so it may be wise to make a copy/backup of that one first.....

good luck!


Wow, that's beautiful... is there a similar one for sc_req_item approval summarizer? We do our approvals at that level.


Here's my hacked version of the approval summarizer for sc_req_item. I'm sure there is some cleanup that can be done.



<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" 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 Requested 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">${sc_req_item.cat_item.sys_meta.label}: </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('Request - requested for user')}:</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('Request created by')}:</label>
</td>
<td>
${sc_req_item.request.opened_by.getDisplayValue()}
</td>
</tr>

<tr>
<td class="label_left" width="150px">
<label style="margin-left: 10px">${sc_req_item.price.sys_meta.label}: </label>
</td>
<td>
<g:evaluate var="ni" expression="
var totalPrice = sc_req_item.price.toString();
if (totalPrice != '') {
totalPrice = parseFloat(totalPrice);
totalPrice = totalPrice.toFixed(2);
}
"/>
${totalPrice}
</td>
</tr>

<tr>
<td class="label_left" width="150px">
<label style="margin-left: 10px">${sc_req_item.request.special_instructions.sys_meta.label}: </label>
</td>
<td>
${sc_req_item.request.special_instructions}
</td>
</tr>


</table>
</td>
</tr>
<j:set var="jvar_line_num" value="0" />
<tr>
<td width="100%">
<table width="100%">

<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>


Based on that, I was also able to put something similar in my mail template. I remove "false" entries (checkboxes that aren't checked) and empty text entries. A little HTML table formatting makes it a little more readable:


Your approval/rejection is required on the following IT Service Desk item. Please review this item and use the links below to take the neccessary action.

Item Description: ${sysapproval.short_description}
Requested For: ${sysapproval.request.requested_for}
<mail_script>

var unitPrice = current.sysapproval.price.toString();
var qty = current.sysapproval.quantity.toString();

if (unitPrice != '') {
unitPrice = parseFloat(unitPrice);
unitPrice = unitPrice.toFixed(2);
}

var totalPrice = unitPrice * qty;

if (totalPrice != '') {
totalPrice = parseFloat(totalPrice);
totalPrice = totalPrice.toFixed(2);
}

template.print('Unit price: $' + unitPrice + '\n');
template.print('Quantity: ' + qty + '\n');
template.print('Total: $' + totalPrice + '\n');

template.print('\n<u>Request Item Details:</u>\n');
//
// Run through the variables
//
var key;
template.print('<table>\n');

for (key in current.sysapproval.variables) {
var currentVar = current.sysapproval.variables[key];

if (currentVar.getDisplayValue() != 'false' &amp;&amp; currentVar.getDisplayValue() != '') {
template.print('<tr><td');
if (currentVar.getDisplayValue() == 'true')
template.print(' colspan="2"');

template.print('>');
template.print(currentVar.getGlideObject().getQuestion().getLabel());

if (currentVar.getDisplayValue() != 'true') {
template.print('</td><td>'+ currentVar.getDisplayValue());
}
template.print('</td></tr>\n');
}
}
template.print('</table>');
</mail_script>

Special Instructions:
${sysapproval.request.special_instructions}
<hr/>
${mailto:mailto.approval} via email
<hr/>
${mailto:mailto.rejection} via email
<hr/>
Click here to view Approval Request: ${URI}
Click here to view the details of the ${sysapproval.sys_class_name}: ${sysapproval.URI}


This was great. I was looking for a way to fix the RITM approval screen since it was showing all the RITM that were under a REQ instead of just the one the approval was for. When I saw this also showed the variables I was thrilled. I checked it out and it worked just fine. You guys are great!