Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Hide Annotation with Client Script

Not applicable

Is it possible to hide an Annotation with a client script the way we can make fields visible/invisible?

I'd like to be able to hide an Annotation along with a set of fields for a specific set of users.

As a workaround, I suppose I could create an actual field with a colored label, but that seems like brute force.

15 REPLIES 15

I am also running into the blank annotation area and the container gap.   Has anyone found a resolution for this or a workaround?



find_real_file.png


Hi,


I got the same issue today. I tried using <span> instead of <div>, and it works. I don't see a gap anymore. Hope this helps!


Community Alums
Not applicable

Hi Veena,



Could you please elaborate on using of SPAN tag. I too tried to use it.


But the box just got reduced rather than getting completely disappeared.


Below is what I have written :



Annotation desc :



<span id="div1" >


Testing Annotation


</span>



Client script :



function onLoad() {


    //Type appropriate comment here, and begin script below


      var stageTest = g_form.getValue('u_stage');


    if (stageTest == 0)


{


div1.style.display = 'false';


}


}



Regards,


Sunil


Hi Sunil,



This is what worked for me: For the annotation, I named it as- <span id="anno1">This is a heading</span>



Then in a client script:



document.getElementById("anno1").parentNode.style.display="none"; //This is to hide the annotation


document.getElementById("anno1").parentNode.style.display="block"; //This is to display the annotation



You'll have to write both onChange and onLoad client scripts because when you write only onChange, they don't work when the form is saved and reloaded.


Daryll Conway
Giga Guru

How are you currently hiding the annotation area?



Did you use


g_form.setVisible('field_name_here', false);



or


g_form.setDisplay('field_name_here', false);