- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
As most forms tend to use visual HTML tags, I will discuss now about ServiceNow html fields because it's interesting the different behavior when working with HTML fields and string fields that contains HTML tags.
Lets talk about:
- HTML fields and string fields in ServiceNow
- Setting the example on the Email client
- Testing html fields by adding formatted string text to be used on the HTML field
- Testing html fields by adding a string with HTML code inside to be used on the HTML field
- Testing html fields by adding a HTML field into a HTML field
HTML fields and string fields
An HTML field allows users to define how field content is rendered by using HTML. Knowledge articles, service catalog item descriptions, release documentation, and HTML content blocks are common examples of HTML fields.
Strings fields are character string. For String type fields, a length of under 256 appears as a single-line text field and anything 256 characters or over appears as a multi-line text box.
Setting the example on the Email client
The ServiceNow email client enables you to send email directly from any record (such as an incident, change request, problem, or user record).
After you enable the email client for an application, users see an email icon in the header bar for each application record.
Click the email icon to launch the email client as a pop-up window. If the window does not appear, verify that your browser is not blocking pop-ups
I will use the email client to create a simple example on how the field type affects the HTML fields display results.
Based on a simple example, I've created an Email "Quick message" with body:
Title of Quick Message | test-non-html-fields | |
Body | test ${u_new_html_field} |
Then, I added a new field into the incident table based on the testings.
Testing html fields by adding formatted string text to be used on the HTML field
In the incident table, I added a formatted string text into a HTML field, the format is lost.
Field Name | u_new_html_field | |
Type | String |
Results: When String fields are added to HTML fields, some format is lost.
Note you can create workflow to transform the string value into the wanted HTML code.
Testing html fields by adding a string with HTML code inside to be used on the HTML field
In the incident table, I changed the value of the u_new_html_field string. When adding a string that contains HTML code into a HTML field, it gets display property in HTML.
Field Name | u_new_html_field | |
Type | String |
Results: When string fields are added into HTML fields, the do not get escaped. They are just added.
Testing html fields by adding a HTML field into a HTML field
In the incident table, I changed the u_new_html_field type to HTML. This is perfect match. The results looks exact like the source data was displayed
Field Name | u_new_html_field | |
Type | HTML |
Results: HTML fields added to HTML field do not get transformed. This is a good choice for copy-paste fields.
In conclusion, if you need to add HTML text into a HTML field, you should either have a String field with
the final HTML code or an HTML field as the source to avoid formatting problems. I have tested using Fuji and Chrome as the browser.
More information can be found here:
Using HTML Fields - ServiceNow Wiki
Thanks joaorodrigues
- 9,050 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.