How to hide the annotations on the form

abhishekte
Mega Expert

Hi,

 

I have created the annotations on my form and under that I have some field.I have hidden that field using UI policy but the annotation is still visible.

Please let me know when we can hide the annotation.

 

Thanks

9 REPLIES 9

acretion
Tera Expert

This seems to work:



First, give your annotations a div id as outlined in the comments by janani in this post:


Annotation gap



In my instance I made a blue info box annotation with the following entry



<div id="anno1">Test annotation</div>



Next, write a client script to fiddle with it. I wrote mine as an onLoad script but I did a quick test using onChange and it seemed to work there too.



function onLoad() {


    //Type appropriate comment here, and begin script below


    document.getElementById("anno1").parentNode.style.display="none";


}




Hope that works for you


@acretion This is working a little too well for me;



It will indeed hide the annotation but I can't make it reappear based on a second script



I have your script above as well as



function onChange(sysIDs, table, oldValues, newValue, callback) {


var sc = g_form.getValue('subcategory');  


if (sc == "App2") {  


  anno1.style.display = "block"; }


  else anno1.style.display = "none";


}



Any ideas?


Try this one.   (You can change it back to storing the subcategory in a different variable if you want, I normally just use newValue).   Edit - I just realized you might have this client script running onChange to a different variable than subcategory, so I got rid of the newValue bit.




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


        if (isLoading) {


          return;


    }


    var sc = g_form.getValue('subcategory');


    if (sc == "App2") {


          document.getElementById("anno1").parentNode.style.display="block";


    }


    else {


              document.getElementById("anno1").parentNode.style.display="none";


    }


}



Then you could also change the onload script to leave the annotation visible if the subcategory is already set to App2 when the page loads.



function onLoad() {


    //Type appropriate comment here, and begin script below


    if (g_form.getValue('subcategory') != "App2"){


        document.getElementById("anno1").parentNode.style.display="none";


    }


}


rsanon
Tera Contributor

I am looking to do something similar...



I have an On Change Client Script, I would like to show an annotation label only show when a particular value is selected



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


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


          return;


    }


  if (newValue == 'Yes')


  {


    document.getElementById("ano1").parentNode.style.display="block";


  }


  else


  {


  document.getElementById("ano1").parentNode.style.display="none";


  }



}



The choice value defaults to none, when I load the page, the label is still present. I only want the label to be present when "Yes" is selected as a choice.



Not sure what is missing to achieve this. Any ideas?