Add Annotations on Service Portal Form Widget fields

F_bio Gon_alves
Tera Expert

Hi SNC,

I realized some time ago that the annotations that we add to form fields do not appear on Service Portal's Form Widget.

How can I work around this problem? Or better, how can I add an "annotation-like" title for example to a specific field on Service Portal's Form widget?

Thanks in advance,

Fábio Gonçalves

1 ACCEPTED SOLUTION

nash3
Giga Contributor

Hi Fabio



I came across the same issue recently too so thought I'd post the fix I got to after doing some research - some suggest ServiceNow have categorised this as an enhancement but I think it does seem to be a bug in ServiceNow, but regardless in the meantime, you can get around it with a Client Script:



1) Search for Client Scripts module from the filter navigator


2) Click New to create a new client script and give it a Name


3) Select your table where your form is running off, ensure your UI Type field is set to Both (for some odd reason the script won't work on the Service Portal view if you set to Desktop only)


4) In the script section, you need to use a small script - showFieldMsg(String field, String message, String type) which is explained here. E.g. following this example, I put in the following for my field and text I wanted to display, so you can copy and paste the following script:



function onLoad()


          {


                  g_form.showFieldMsg('u_first_name','this is my text.','error');


          }



Then replace the above for your use case:



'u_first_name' - change this to the name of the field you want to display the text under


'this is my text' - replace with the text you want to display


'error' - error shows a red background, or replace with 'info' to show a blue background



5) Save the script - it will show similar to an annotation under the field on the Service Portal. The script record should look something like this below



find_real_file.png



Hope this helps - please accept this as the correct answer if it works for you


View solution in original post

8 REPLIES 8

Harsh Vardhan
Giga Patron

Hi Fabio,



I would suggest connect with Hi Team.



you can refer the link below. hope it will help you.



Annotations in ServicePortal - Form Widget



Thanks,


Harshvardhan


Hi harsh vardhan,



I'm sorry, but what it the Hi Team exactly? I'm just no familiarized with the term.




Thanks,



Fábio Gonçalves


nash3
Giga Contributor

Hi Fabio



I came across the same issue recently too so thought I'd post the fix I got to after doing some research - some suggest ServiceNow have categorised this as an enhancement but I think it does seem to be a bug in ServiceNow, but regardless in the meantime, you can get around it with a Client Script:



1) Search for Client Scripts module from the filter navigator


2) Click New to create a new client script and give it a Name


3) Select your table where your form is running off, ensure your UI Type field is set to Both (for some odd reason the script won't work on the Service Portal view if you set to Desktop only)


4) In the script section, you need to use a small script - showFieldMsg(String field, String message, String type) which is explained here. E.g. following this example, I put in the following for my field and text I wanted to display, so you can copy and paste the following script:



function onLoad()


          {


                  g_form.showFieldMsg('u_first_name','this is my text.','error');


          }



Then replace the above for your use case:



'u_first_name' - change this to the name of the field you want to display the text under


'this is my text' - replace with the text you want to display


'error' - error shows a red background, or replace with 'info' to show a blue background



5) Save the script - it will show similar to an annotation under the field on the Service Portal. The script record should look something like this below



find_real_file.png



Hope this helps - please accept this as the correct answer if it works for you


HI Nash Porath ,



That worked just perfect!
Thanks for your help.




Best regards,



Fábio Gonçalves