How to hide label if data is empty in servicenow portal

test2service
Tera Contributor

Here I am sharing my HTML and Server script

function getSla(itemID) {
		var gr; 
//Get current record  
gr = $sp.getRecord(); 
//Check whether record is invalid 
if (gr == null || !gr.isValid()) { 
data.isValid = false; 
return; 
} 
		var sla = [];
		var gr = new GlideRecord('contract_sla');
		gr.addEncodedQuery('start_conditionCONTAINS' + itemID);
		//gr.addEncodedQuery('start_conditionSTARTSWITHcat_item');
		gr.query();
		while(gr.next()) {
			var sla_item = gr.getValue('name');
			sla.push(sla_item);
		}
		return sla.join(',');
	}
	var catTest2 = $sp.getParameter('sys_id');
	var gp2 = new GlideRecord('sc_cat_item');
	gp2.addQuery('sys_id', catTest2);
	gp2.query()
	while (gp2.next()){
		//data.hasFulfillment = xyz.u_fulfillment ? true : false;
		data.xyz = gp2.getValue('u_fulfillment');
	}
		})();


HTML
<div>
  <div class="row">
  <div class="col-md-6 col-sm-12">
<b>Fulfillment:</b>
    </div>
<div class="col-md-6 col-sm-12 catalog-text-wrap">
  {{data.xyz}}
</div>
  </div>

<div class="row">
  <div class="col-md-6 col-sm-12">
    <b>SLA:</b>
  </div>
  <div class="col-md-6 col-sm-12 catalog-text-wrap">
    {{data.sla}}
  </div>
</div>
</div>
0 REPLIES 0