Hide Show Annotation

cspra
Giga Expert

Hello,

I was trying to HIDE / SHOW an Annotation, if particular business condition is met.

Unfortunately, after trying this via CLIENT SCRIPT and UI POLICY and by also following steps from different forums, it still didn't work.

Here's my Annotation HTML script (FORM Layout / Form Design) Excerpt ONLY:

<divid id="anno1" style = "line-height:2; font-size:13.4px;">Attachment Required</divid>

In CLIENT SCRIPT and UI POLICY Excerpt ONLY:

var statusx = g_form.getValue('status');

if (statusx == 'Draft'){

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

}

else {

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

}

}

The Browser DEV Tool is giving me this error -

Uncaught TypeError: Cannot read property 'getElementById' of null

Am I missing something here?  

Appreciate your time.

12 REPLIES 12

Strange


Same logic is working fine for me. have tested this in Istanbul version. Please find the screenshots below:



find_real_file.png



find_real_file.png



Client Script:



find_real_file.png



Result:



find_real_file.png




Will suggest you make sure your field name is correct and the value which you are checking for the state field is correct or not. In your second line double check the backend value of status field whether it is "Draft" or a numeric value.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Thanks for the effort Shloke.   Yes this is totally strange.   Our approach work as well on my personal instance.


We just discovered solution by directly using the ID itself to manipulate the display.


Here -


anno1.parentNode.style.display="none";



I also hope that others who are facing the same issue can find this alternate approach useful.


Thank you for sharing this. The same thing happened with me.

 

This piece of code was working everywhere in the system, except for one particular annotation for no reason

document.getElementById("anno_id").parentNode.style.display="block" 

 

I was struggling for one week until I find yours solution

 

annotation_id.parentNode.style.display="block";

divya mishra
Tera Guru

Hey there,



Could you please try using gel instead of document.getElementById.


Also would request you to check the value of status you are getting   if its numeric or string.


Let me know if this was helpful.



Thanks for the suggestion Divya.   However, I am more inclined to use document.getElementById as I find it a straightforward solution.   I am not sure if I am missing something in my above approach.