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

Michael Fry1
Kilo Patron

There is a client script out of the box that show/hide an annotation. The client script is named: Hide script annotation if simple ref


The script looks like this, if it helps:


function onLoad() {


      if(g_form.getValue('simple_reference') === 'true') {


              if(SN && SN.formAnnotations) {


                      var pref = SN.formAnnotations.preference;


                      var infoPref = SN.formAnnotations.infoPreference;


                      SN.formAnnotations.preference = false;


                      SN.formAnnotations.infoPreference = false;


                      CustomEvent.observe('page_loaded_fully', function restoreAnnotationPreferences() {


                              SN.formAnnotations.preference = pref;


                              SN.formAnnotations.infoPreference = infoPref;


                      });


              }


      }


}


Thanks!   How would I apply this client script?


Change the if statement to meet your requirements.



      if(g_form.getValue('simple_reference') === 'true') {


Hi Michael,

is it possible to put this script into a UI Policy?  I'm trying to hide/show annotations based on a checkbox field on a form...would be great to use a UI Policy so I case the "reverse if false".  Any ideas?  thanks!