Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Form Builder - Hide Header Annotation

Dimitrios Hatzi
Tera Contributor

Hello there,

 

I am trying to understand if I am able to hide an annotation (Header Text) from my incident form/view: Test

 

The scenario (UI policies applied to the fields):

  • If the Funded File field is set to "none", the Header Text annotation and the two fields below it, are hidden.
  • If the Funded File field is set to "yes", the Header Text annotation and the two fields below it, become visible.

My first attempt:

I created the form like this (merged with the section above):

 

DimitriosHatzi_1-1777053192332.png

but when form loads, and the Funded File is set to "none" I see this:

 

DimitriosHatzi_2-1777053296021.png

 

If I switch it to "yes", I see this:

 

DimitriosHatzi_3-1777053376936.png

 

Ultimately, I want the "File Funded" - Text Header Annotation to be hidden too.

 

My second attempt:

I created the form like this (without merging):

 

DimitriosHatzi_4-1777053698733.png

 

but when form loads, and the Funded File is set to "none" I see this:

 

DimitriosHatzi_5-1777053743380.png

 

If I switch it to "yes", I see this:

 

DimitriosHatzi_6-1777053810737.png

 

My third attempt (no merging and 3 sections):

 

The first section is the only section visible and the other two become tabs:

 

DimitriosHatzi_7-1777053964109.png

 

Am I asking much? Is there an alternative to hide the Header Text annotation. I know UI policies do not apply on annotations but there must be a way. I do not want to use the tab sections. Is there any hope?

 

Thank you

 

Dimitri

2 REPLIES 2

Rakesh_M
Tera Guru

Hi @Dimitrios Hatzi ,
You can hide a annotation by DOM Manipulation
Create your annotation as rich text and give an ID to it.

<span id="hide-text"><p>Annotation Text</p></span>

now create a onChange client script

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (newValue=="yes" ) {
        var ann = document.getElementById("hide-text");
        ann.style.display = "none";
    } else {
        var ann = document.getElementById("hide-text");
        ann.style.display = "block";
    }
    //Type appropriate comment here, and begin script below

}



Tanushree Maiti
Kilo Patron

Hi @Dimitrios Hatzi 

 

 

Using DOM Manipulation you can achieve it. Without DOM , It is not feasible.

 

<div id="annotation_lbl"> Your Annotation Text </div>


UI Policy Script (Triggers if Funded File field is set to "yes",)

execute if true

function onCondition() {
var lblAnnotation = document.getElementById("annotation_lbl");
lblAnnotation.style.display = 'block';
lblAnnotation.parentElement.style.display = 'block';
}


execute if false

function onCondition() {
var lblAnnotation = document.getElementById("annotation_lbl");
lblAnnotation.style.display = 'none';
lblAnnotation.parentElement.style.display = 'none';
}

 

Refer link: https://www.servicenow.com/community/itom-forum/how-to-hide-the-annotations-on-the-form/m-p/984670/p...

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: