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

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

To answer number 3: It's because Service Portal counts itself as a mobile device and therefor you need "both" to get it working.



Otherwise for this, I would redo the widget instead to use the help field on the items. In a bigger environment this would mean a lot of client scripts and hard to have a catalog manager to manage items if they need to create client scripts for help texts.


Hi Goran Lundqvist,



That is true. For a huge number of fields this approach would be impossible to achieve.



What did you mean by "to use the help field on the items"?




Best regards,



Fábio Gonçalves


Hi Fabio,



Sorry,


I mixed up this post with another one I was responding at the same time where there help field on the catalog items doesn't show like you want it to do in the Service Portal.


Eli Guttman
Tera Guru

Hi,

I'm looking for similar solution, but i need to be able add a link (HTML) in the message.

Does anyone know how to do it?

 

Thank you!