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

I think in this case it won't work because it is a check box variable . Go with select box variable type and include drop down values as none, true, false.


Can I use this to hide Empty fields on the Approval Summarizer for Change Request as well?



I am trying to hide empty fields in the approval summarizer and the code above seems like it only applies to service catalog.


This code is only for Service Catalog and the OOTB UI macro for Change request table is "approval_summarizer_default" in which they are calling approval view of Change request. So the fields which are added to approval view are displayed by default in approval summarizer for change request. I don't know where exactly we have to modify this script to hide empty variables but I think we can do this by modifying the script.


Thank you for the prompt response! and yes, thats exactly what its doing. I will post the answer if I solve this one. Seems like it hasnt been answered on the wiki yet.



Thank you


User672379
Tera Contributor

This post is a little old, but I wanted to mention in the OP's post they're using the Variable Editor to display the variables, which presents the variables in the same format as it does on RITM/Task forms.  The replies are for other macros being used i.e. custom macros, approval_variable_summary, etc. and do not really answer the question on how to hide empty variables in the Variable Editor.

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

Does anyone know how to do this within the Variable Editor itself?

This KB from SN alludes to the fact that you could copy the Variable Editor being used for RITMS/Tasks, and customize it, but I haven't found any other information on the subject.

https://hi.service-now.com/kb_view.do?sysparm_article=KB0694706

3) The 'Approval Summarizer' UI Formatter currently uses 'approval_summarizer_master.xml' formatter which is embedded in our base code and not possible to customize. Alternately, you could build a custom UI Macro similar to 'com_glideapp_servicecatalog_veditor' and use this formatter instead and implement your customizations there. However we would need customers to own this, as customized implementations are beyond support scope.