How to hide empty variables in approval form

mdsannavulla
Kilo Guru

Hi All,

 

Below is the UI macro (approval_summarizer_sc_req_item) we are using.This one is modified not OOTB code.

 

In this ui macro how to hide empty variables>please provide any information

 

<?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"> Summary of Task being approved:

  <g:label_spacing/> </label>

  </td>

  </tr>

  <g:evaluate var="jvar_ni" expression="

  var task = ${ref}.sysapproval;

  "/>

 

  <tr>

  <td>

  <table width="100%">

  <tr>

  <td class="label_left" width="150px">

  <label style="margin-left: 10px">Short Description: </label>

  </td>

  <td> ${task.short_description}

  <g:label_spacing/> </td>

  </tr>

  <tr>

  <td class="label_left" width="150px">

  <label style="margin-left: 10px">Requested By</label>

  </td>

  <td> ${task.request.opened_by.getDisplayValue()}

  <g:label_spacing/> </td>

  </tr>

  <tr>

  <td class="label_left" width="150px">

  <label style="margin-left: 10px">Requested For</label>

  </td>

  <td> ${task.request.requested_for.getDisplayValue()}

  <g:label_spacing/> </td>

 

 

  </tr>

  <tr>

  <td class="label_left" width="150px">

  <label style="margin-left: 10px">Description:</label>

  </td>

  <td class="tdwrap"> ${task.description} </td>

  </tr>

                                                              <tr>

                                                                        <j:set var="jvar_old_ref" value="${ref}"/>

                                                                        <g:evaluate>var sc_task = new GlideRecord('sc_req_item'); sc_task.get(task);</g:evaluate>

                                                                        <j:set var="ref" value="sc_task" />

                                                                        <j:set var="jvar_questionset_read_only" value="true" />

                                                                        <td colspan="2"> <g:render_component componentName="com.glideapp.servicecatalog.variables.VEditor" /></td>

                                                                        <j:set var="ref" value="${jvar_old_ref}" />

                                                              </tr>

 

 

  </table>

  </td>

  </tr>

</j:jelly>

1 ACCEPTED SOLUTION

mdsannavulla
Kilo Guru

For this we have to modify below UI macro



approval_variable_summary



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


  <g:evaluate>


                                              var set = new GlideappVariablePoolQuestionSet();


                                              set.setRequestID('${jvar_sc_req_item}');


                                              set.setTaskID('${jvar_sc_task}');


                                              set.load();


  </g:evaluate>


  <table cellspacing="10" cellpadding="0" width="100%" style="background-color: #fffff0;">


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


<!-- Hiding empty variables by Sana -->  


                                                                    <j:if test="${jvar_question.isVisibleSummary()&amp;&amp;jvar_question.getDisplayValue() != ''}">


  <g:summarize_question question="${jvar_question}" />


                                                                    </j:if>


  </j:forEach>


  </table>




</j:jelly>


View solution in original post

14 REPLIES 14

This is good! How do you address for the variables that result in "False" or "None"


If the field value is None means it is empty and it will not be displayed but if the value is false means it displays the field on the form.


If it is a drop down, it will default to"-none-"


if it is a check-box, it will default to "false"


How can we manipulate the code, so it will only show variables on the approval summary page, that are relevant to the options selected


If you don't want to show the fields which are having value false then try like this



&amp;&amp;jvar_question.getDisplayValue() != 'fasle'


But that wont always be the case, I do want the field to be present, if it is related the option (show/hide UI Policy) being selected.