Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Do UI Policies work on Break Variables?

Mark_Didrikson
ServiceNow Employee
ServiceNow Employee

Hello,

 

Can you use a UI Policy to hide a Break Variable on a Catalog Item?   Can't seem to get this to work.   Also, tried using a Catalog Client Script.

 

Thanks!

 

Mark Didrikson

4 REPLIES 4

justin_drysdale
Mega Guru

I am on Calgary. From what I can see of a break variable, it is:


<tr id='io_break'>


  <td>


      <hr></hr>


  </td>


</tr>


in the markup.



The break variable didn't respond to setVisible() nor setDisplay() so I used DOM methods.



One fast way to hide it:


var breaks = document.getElementsByClassName('io_break');


for(var i in breaks) {


breaks[i].style.display = 'none';


}



Unfortunately this will hide ALL the breaks on the page, which is probably not what you intend.   If you wanted to hide a specific break it gets more messy.   You can experiment until you find the break you are looking for:



var breaks = document.getElementsByClassName('io_break');


alert('hiding 1st break');


breaks[0].style.display = 'none';


alert('hiding 2nd break');


breaks[1].style.display = 'none';


alert('hiding 3rd break');


breaks[2].style.display = 'none';


//etc...



Good luck!


Mark_Didrikson
ServiceNow Employee
ServiceNow Employee

Thanks! Very helpful.


Aaron40
Kilo Guru

Are you saying you can't hide a break variable conditionally via a UI policy? If not, have you tried adding the break inside of a container and hiding the entire container?


putting them in a container worked perfectly for me.