How to get the ID of an Annotation in form?

asfaque
Tera Contributor

Hi All,

I want to create an blue box Annotation and make it hide and re-appear through onChange() client script when the user change the state of the request. I know the coding for Client script except the Annotation ID. Please help me in finding Annotation ID.

1 ACCEPTED SOLUTION

nthumma
Giga Guru

I use below code to hide annotations , I have 3 annotations and i am hiding 3rd annotation.


var refs = document.getElementsByClassName("annotation-wrapper");


refs[3].style.display = 'none';


View solution in original post

4 REPLIES 4

nthumma
Giga Guru

I use below code to hide annotations , I have 3 annotations and i am hiding 3rd annotation.


var refs = document.getElementsByClassName("annotation-wrapper");


refs[3].style.display = 'none';


Hafsa1
Mega Sage

Hi Asfaque,



Can you share client script?


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.



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';
}