How to Create and Show/Hide Annotations in a Form

ArTex
Tera Contributor

𝐇𝐨𝐰 𝐭𝐨 π‚π«πžπšπ­πž 𝐚𝐧𝐝 𝐒𝐑𝐨𝐰/π‡π’ππž π€π§π§π¨π­πšπ­π’π¨π§π¬ 𝐒𝐧 𝐚 𝐅𝐨𝐫𝐦
Annotations are essential in ServiceNow forms as they enhance user experience, reduce errors, and provide additional support, making processes more intuitive and efficient.

How to create an Annotation

Open the 'Personalize Form Layout' page in the form > Locate the field type '*Annotation' > Select it for the form view.

ArTex_0-1744267029955.png

Annotation Details:

Form Annotation Type –> table 'sys_ui_annotation_type' – where you can define the <style> for your HTML annotation text:

ArTex_2-1744267059092.png

 

To add the content to the text, we will create a Message in the 'sys_ui_message' table in HTML format:

ArTex_4-1744267059094.png

 

After selecting the Style and creating the Message, we can now create the Annotation:

ArTex_6-1744267059096.png

 

View the Annotation in the Form:

ArTex_7-1744267059096.png

 

How to show/hide an annotation through a Client Script

I added a new variable for the demonstration. If the 'Select to hide' checkbox is selected, I want the annotation to be hidden.

ArTex_8-1744267059097.png

 

To do this, we need to reconfigure the annotation:

Open the 'Personalize Form Layout' page in the form > Locate the previously created annotation.

Add an id attribute as a unique identifier for the text so we can reference it in the client script:

ArTex_10-1744267059101.png

New Client Script:

Note: The 'Isolate script' field must be set to false, i.e., not selected.

ArTex_18-1744267375537.png

 

View of the result in the form:

ArTex_20-1744267411363.pngArTex_19-1744267411363.png

0 REPLIES 0