Show/Hide Annotation UI Policy not working

davilu
Mega Sage

Hi Experts,

I have two annotations on a form and I'm trying to show/hide only ONE of them based on a particular answer.   I've tried adding an id to my annotation and then using the UI Policy script conditions to show/hide the annotation, but it's not working.   I gave my annotation an id = "other" and I created this UI Policy:

Execute if true:

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

Execute if false:

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

When I run the form, both annotations are gone and when I change my answer to that particular field to Yes, I get this error:

onChange script error: TypeError: Cannot read property 'getElementById' of null function (){var o=i(m,arguments);return l.apply(n,o)}

What am I doing wrong here?

Additionally, when I add <div id="other"> to my annotation, it adds another box and an input onto the form...

find_real_file.png

When looking in the console, it adds an additional div and an input:

find_real_file.png

7 REPLIES 7

Haven't tried but I see a script on a UI Policy out of box. Looks hard-coded, but maybe will work for you:

function onCondition() {
	if(document.getElementById('group_tip'))
		$j('#group_tip').parents('.annotation-wrapper').css("display", "block");
}

update group_tip to fieldname in 2 places.

"block" shows, change to "none" to not show.

Hi Michael, in a different post I saw someone posted this script at a solution.

test.parentNode.style.display = "none";//where "test" is the element ID of my annotation

I put this in the "Execute if false" script and it works perfectly.

find_real_file.png

I am trying to hide an annotation (one of many) in an on Change client script.

1) I place the above code in my script but it does not work -- I don't see any statement to identify which annotation i want to hide

2) I have multiple annotations and want to hide only 1 in my client script, how do i identify which annotation i am manipulating?