Hiding empty variables on an approval form

If you have created a service catalog item that has an associated workflow, you may have found that all variables captured on the request are displayed on the approval form in the variable summary section.  Depending on how the catalog item is constructed, there may be a number of variables that you don’t want to be display or are simply empty because the fields were not relevant for the particular request.  There are two solutions to this based on if a field should never be displayed in the summary or only displayed if it is not empty.

The first case, when a field should never be displayed, is pretty easy.  By default, the form to manage a variable on a catalog item, does not display the option “Visible on Summaries”.  To enable this, you will need to Personalize the Form Layout of the Variable item view and move “Visible on Summaries” to the Selected side of the slush-bucket.  By default, this field is selected for all variables.


If you never want to have a variable display on the approval variable summary, simply un-check this option and it won’t display.


The second option (hiding empty variables) is a bit more involved and requires some understanding of how the actual variable summary is generated.  Within ServiceNow, there are UI Formatters (System UI->Formatters).  To see how to create a formatter, you can review the article on the ServiceNow wiki.  The formatter in this case is called Approval Summarizer and defines the associated table and formatter xml that will be used.  These formatter xml documents are really UI Macros written in Jelly.  Through a number of Jelly calls, we eventually end up at the approval_variable_summary UI Macro.  It is this macro that we need to update to hide the empty variables.  The following snippet shows the updates in bold-italic which are used to check and see if a particular variable’s value is either empty (” – single quotes) or in the case of a select list, set to ‘– None –‘.

 <j:forEach var=”jvar_question” items=”${set.getFlatQuestions()}”>

<j:if test=”${jvar_question.isVisibleSummary()}”>
                    <j:if test=”${jvar_question.getDisplayValue()!=”}”>
                         <j:if test=”${jvar_question.getDisplayValue() != ‘– None –‘}”>
<g:summarize_question question=”${jvar_question}” />

Using these two options will allow you to clean up the approval variable summary without a great deal of complication.

Posted in Approval Management.