Show/Hide Annotation UI Policy not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 03:53 PM
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...
When looking in the console, it adds an additional div and an input:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 07:43 PM
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;
});
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 07:48 PM
Thanks! How would I apply this client script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2017 07:53 PM
Change the if statement to meet your requirements.
if(g_form.getValue('simple_reference') === 'true') {
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 04:26 PM
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!