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

Kalaiarasan Pus
Giga Sage

you might use this for displaying the variables ... not the best but will do the job... you will need to alter the look and feel as required...



<g:evaluate jelly="true">


var set = new GlideappVariablePoolQuestionSet();


set.setRequestID(${ref}.sysapproval.sys_id);


set.load();


</g:evaluate>



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


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


<tr>


<td>


${jvar_question.getLabel()}


</td>


<td> ${jvar_question.getDisplayValue()}


</td>


</tr>


</j:if>


</j:forEach>


Hi Kalai,


I need your advice on Need to change approval summarizer for checkbox type variables


Please share your thoughts.


Anurag Tripathi
Mega Patron
Mega Patron

Hi,



I think this is what you want to do:



Write a javascript code to read each item in the macro using id (DOM) to check whether its blank or not, if it is you can hide it using DOM like this



document.getElementById("<id of your field>").style.visibility="hidden";




This code will cone in your ui macro itself inside <script></script> tags.






-Anurag

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>