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

Rachelle,



An onChange script won't run when the initial form load happens, it will only be triggered when the field the onChange script is written on changes.   I'd suggest writing an additional onLoad script to hide the annotation when the form loads unless your conditions are already met.


rsanon
Tera Contributor

Thanks for the feedback!! I was trying to avoid having both an "On Change" & "On Load" Client Script, but looks like that's just what i'll need to do.


Hi have you thought about using UI policies and the "Run Scripts" option? You can then just use the relevant line of code


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


or


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



in the "Execute If true" and "Execute if false"



This worked a treat for me - runs on display and change, with simple condition buiilder


Hello Rachelle, If you want to run onChange script at the time of onLoad then you can do that by removing   if (isLoading || newValue == '') {             return;     } this code and you can avoid two scripts. Thanks, Dhananjay


nigelharrison
Giga Contributor

Just went through the pain of getting this to work and our developer fixed the following.

Created a UI policy against the field you want to show the annotation against. In this case, a 'Yes/No' field, annotation only to show on YES and hide when none or NO.

UI Policy Script

execute if true

function onCondition() {
var refs3 = document.getElementsByClassName("annotation-wrapper");
refs3[24].style.display = 'block';
}

 

execute if false

function onCondition() {
var refs3 = document.getElementsByClassName("annotation-wrapper");
refs3[24].style.display = 'none';

}


This annotation is the 25th annotation, in 'form design' you count them 0-24.

The obvious problem to be aware of.
If annotations are added or removed above this annotation then the script will start hiding the new 25th annotation.

 


So we amended and added the label feature in the annotation to pick up specific annotation, no need to number them.

In the annotation you need to a a lablel.
<div id="annotation_label"> Annotation Text Goes Here </div>


UI Policy Script

execute if true

function onCondition() {
var refs3 = document.getElementById("annotation_label");
refs3.style.display = 'block';
refs3.parentElement.style.display = 'block';
}


execute if false

function onCondition() {
var refs3 = document.getElementById("annotation_label");
refs3.style.display = 'none';
refs3.parentElement.style.display = 'none';
}