Restrict Visibility of UI Macro

Ravi56
Giga Contributor

Hi All,


I have created a UI Macro which basically adds an icon   next to reference field on incident form. On click of this icon,user will be redirected to list of change records.Now I want to show/hide this UI macro based on priority of incident.


Any inputs on how to achieve this?

1 ACCEPTED SOLUTION

Gurpreet07
Mega Sage

I hope you have been assigned ids to the HTML elements you created in UI Macro. You could make use of those element ids in an onLoad or onChang priority client script to hide the macro.


gel("element_id").style.display = "none" ;


View solution in original post

7 REPLIES 7

Gurpreet07
Mega Sage

I hope you have been assigned ids to the HTML elements you created in UI Macro. You could make use of those element ids in an onLoad or onChang priority client script to hide the macro.


gel("element_id").style.display = "none" ;


Hey Gurpreet,


could you expand on this a little?
I'm not a jelly scripter.



here is my UI Macro that i'm trying to hide.  
Could you help me with my client script to hide this.





<?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="jvar_guid" expression="gs.generateGUID(this);" />


<j:set var="jvar_n" value="show_incidents_${jvar_guid}:${ref}"/>


<g:reference_decoration id="${jvar_n}" field="${ref}"


  onclick="pushAndStartCi('${ref}'); "


  title="${gs.getMessage('Push and Start with Bomgar')}" image="jump_bomgar.gifx"/>




<script>


// show related list


// todo: should be part of the PopupWindow class


// todo: needs new stack name


function pushAndStartCi(reference) {


  var taskType = g_form.getValue('sys_class_name');


  if(taskType == 'incident'){


      if(g_form.isNewRecord()){


          alert("You must save your incident before the Bomgar button can be used.");


          return;


      }


  }


  var s = reference.split('.');


  var referenceField = s[1];


 


  var ga = new GlideAjax('Bomgar');


  ga.addParam('sysparm_name', 'generatePushURL');


  ga.addParam('sysparm_record_id', g_form.getUniqueValue());


  ga.addParam('sysparm_ci_id', g_form.getValue(referenceField));


  ga.getXMLWait();


  var url = ga.getAnswer();


  //alert(url);




  if(url.toString().indexOf("Error:") == 0){


      alert("Error connecting to Bomgar! \n Please contact your system administrator!");


  }


  else{


      window.open(url.toString(),'_newtab');


  }


}




</script>


</j:jelly>





What do i need to use in my 'gel' script?


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue === '') {


  return;


  }



  //Type appropriate comment here, and begin script below


  gel("").style.display = "none" ;


}


Steven,



      Right click on the element and inspect it, you will find the id there. you will have to put the id of that element inside gel()




Thanks,


Abhinay



PS: Hit like, Helpful or Correct depending on the impact of the response


Hey Abhinay,



I really hate to ask this, but could you post a picture of where one would be.


I'm not finding an ID anywhere