Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Well then I would suggest to use div instead of divid.


and the below code:


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



Let me know if this was useful


Community Alums
Not applicable

maybe try this keyword eg. this.document....

Damian Martinez
Mega Sage

Hello,

I am on Vancouver version and the latest solution here does not work,  did somebody manage to make this work in Vancouver?

Thanks!