Hide/Display Annotations

Ram150
Tera Expert

I have a form with a few fields and annotations "1" and "2". 1 has to display if the logged in user has a particular role and 2 otherwise.

I've tried using document.getElementById(<id>).parentNode.style.display='block'; on an OnLoad Client Script, OnChange Client Script and UI Policy. I've tried to declare document.getElementById(<id>) to a variable and modify the styling separately. Doesn't work.

I'm on Kingston. If anyone has any experience making this work, please suggest a solution

6 REPLIES 6

sachin_namjoshi
Kilo Patron
Kilo Patron

Use below code to hide annotations.

But, please be careful since every DOM manipulation is not supported.

 

try {


       gel('p1andp2').parentNode.style.display = "block";


} catch (error) {


       console.log('Error with Client Script "Hide Annotation": ' + error);


}

 

 

 

Regards,

Sachin

allison_holt
Giga Expert

Block will display it and none will hide it.  Have you used both in the same script?

if user has role 1

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

document.getElementById(anno2).parentNode.style.display='block;

else if user has role 2

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

document.getElementById(anno2).parentNode.style.display='none';

Yup. I've used both in the same script and also tried putting both in different scripts. No success.

Rahul Kumar17
Tera Guru

hi

https://community.servicenow.com/community?id=community_question&sys_id=3c6c83a5db9cdbc01dcaf3231f96...

If my response helped please mark it correct and close the thread.

Thanks,
Rahul Kumar