Hide Empty Variables on Approval Record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2014 11:33 PM
Hi,
I have a requirement to display the variable editor from the requested item and display it on the approval record and additionally hide the empty variables.
I managed to display the variables on the approval record by modifying the "approval_summarizer_sc_req_item" Macro with the xml from "approval_summarizer_default".
My only issue now is that I want to hide the empty variables on the approval record. I'm able to hide this on the requested item using an on display business rule and client client script (http://www.servicenowguru.com/scripting/business-rules-scripting/hide-empty-variables-standard-form/), however this method will not work on the approval record as the variables are being rendered from the Macro.
Would appreciate if anyone knew how to modify the UI Macro to achieve this result.
Thanks in advance.
Anthony

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2014 11:55 PM
Hi Anthony,
You could hide the variables by putting a if/else block inside your macro itself.
You need to initialize variables before creating HTML table structure, that way you know which variables are empty and need not be shown inside table and you can exclude whole column itself.
<j:set var="jvar_my_variable" value="${some_value}"/>
now before creating a header cell, you could have a simple check like below
<tr class="header">
<j:if test="${jvar_my_variable != ''}">
<td>
Header For My Variable
</td>
</j:if>
Also, you could add below line while populating table data.
<j:if test="${jvar_my_variable != ''}">
<td>
${jvar_my_variable}
</td>
</j:if>
Hope that helps,
Thanks,
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2014 04:16 PM
Hi Mandar,
Appreciate your assistance. On some of my catalog items I have over 400 variables so I would need to loop through the variables to determine if they were empty. I wouldn't be able to to define them as suggested in your example.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2014 10:16 PM
Hi Anthony,
How do you display variables currently in the approval summarizer page? My earlier code was assuming that you display a separate variable in a separate column.
If you could share the way you display the variables currently that'd help to suggest a better way.
Thanks,
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2014 10:23 PM
Hi Mandar,
Thanks once more for your response. I pasted the below XML code from approval_summarizer_default into approval_summarizer_sc_req_item. The result is that it displays all the variables from the requested item variable editor onto the approval summarizer. It looks very good with the exception that the empty variables are also being displayed.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate var="jvar_has_source" >
var flag = !${ref}.sysapproval.nil() || !${ref}.source_table.nil();
flag;
</g:evaluate>
<j:if test="${jvar_has_source}">
<g:evaluate var="jvar_ni" expression="
var gr = null;
if ( !${ref}.source_table.nil()) {
gr = new GlideRecord(${ref}.source_table);
gr.get( ${ref}.document_id);
} else {
gr = new GlideRecord('task');
gr.get(${ref}.sysapproval);
}
" />
<g:evaluate>
g_approval_form_request = true; // this global is checked in ACLs
</g:evaluate>
<g:evaluate var="jvar_my_form">
var gc = new GlideController();
var p = new GlidePopup(gc, "${gr.sys_class_name}");
p.putParameter("sys_id", "${gr.sys_id}");
p.putParameter("sysparm_view", "approval");
//PRB579164: Skip g_form creation in activities.xml if activities displayed in formatter
p.putParameter("sysparm_skip_gform", "true");
var rp = p.getRenderProperties();
rp.setSmallCaption(true);
var s = p.getPopup();
s;
</g:evaluate>
<tr id="approval_summary_row">
<td width="100%" colspan="2">
<j2:if test="${gs.getProperty('glide.security.use_csrf_token')}" >
<input type="HIDDEN" name="sysparm_ck" value="$[gs.getSessionToken()]"/>
</j2:if>
<div id="approval_summary" style="padding-top:8px;display:none;">
<div class="caption" style="padding:4px;">${gs.getMessage('Summary of Item being approved')}</div>
<div style="padding-left:2px;"><g:no_escape>${jvar_my_form}</g:no_escape></div>
</div>
</td>
</tr>
<g:evaluate>
delete g_approval_form_request; // removes the global
</g:evaluate>
<script>
addRenderEvent(moveSummaryForm);
function moveSummaryForm() {
var e = $("approval_summary");
var form = $("sysapproval_approver.do");
var formParent = form.parentNode;
formParent.appendChild(e);
e.show();
}
</script>
</j:if>
</j:jelly>