- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 01:59 PM
Is there any way to show the value of an HTML field properly when it's delivered in a pop-up that shows a UI page?
Right now any HTML comes across as regular text and isn't translated in the XML of the UI Page.
See here for reference: https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/script/client_scripts/reference/r...
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2019 03:44 PM
Hi Shane,
Here's an example of how you can get the values using client script in a UI Page Preview and set the values in the page content.
In the above script, in the Client script section, you'll see that GlideForm,i.e., g_form methods are used to access the value of "short_description". I have included comments to give you an idea of the purpose of those statements.
The values accessed using g_form methods are then set in the UI Page content using DOM Methods (it is not going to get impacted by any upgrade as it is your own HTML code, which is not going to change its document structure).
So, here is the incident form where I tried previewing the UI Page:
And here is the preview result using the UI Page:
This implementation got the results from the client side of the form, not the server side. So you'll get the current values even if they're not yet saved.
Hope this helps!
Cheers,
Manish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 03:50 PM
Did you try placing your HTML content inside no_escape tag?
no_escape
- Description: The system, by default, uses escaped output as a security measure. Output placed inside of
no_escape
tags is not escaped before output. Be careful when using these tags, because if user input is displayed here it can open a security vulnerability on the page. - Parameters: None.
- Example:
<g:no_escape> ${jvar_raw_html_data} </g:no_escape>
Here is an example:
Result:
If I add the no_escape tag:
Result:
Give it a try and see how it goes. Hope this helps!
Cheers,
Manish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 05:28 AM
It didn't seem to work for me.
<b>Reason:  </b><g:no_escape>${jvar_body}</g:no_escape>
Shows:
Reason: <p>Here is the body.</p>
Here is my UI Page code
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<!-- Get the values from dialog preferences -->
<g:evaluate var="jvar_type" expression="RP.getWindowProperties().get('type')" />
<g:evaluate var="jvar_ci" expression="RP.getWindowProperties().get('ci')" />
<g:evaluate var="jvar_start" expression="RP.getWindowProperties().get('start')" />
<g:evaluate var="jvar_end" expression="RP.getWindowProperties().get('end')" />
<g:evaluate var="jvar_time_range" expression="RP.getWindowProperties().get('time_range')" />
<g:evaluate var="jvar_desc" expression="RP.getWindowProperties().get('desc')" />
<g:evaluate var="jvar_loc" expression="RP.getWindowProperties().get('loc')" />
<g:evaluate var="jvar_body" expression="RP.getWindowProperties().get('body')" />
<!-- Set up form fields and labels -->
<i>Subject: </i>
<p></p>
${jvar_type} Notification - ${jvar_desc} - ${jvar_start} ${jvar_time_range};
<p></p>
<i>Email body: </i>
<p></p>
<center><u><b>${jvar_type} Notification</b></u></center>
<p></p>
<b>Date:  </b>${jvar_start}
<p></p>
<p></p>
<b>Time:  </b>${jvar_time_range}
<p></p>
<p></p>
<b>Location(s) affected:  </b>${jvar_loc}
<p></p>
<p></p>
<b>System(s) affected:  </b>${jvar_desc}
<p></p>
<p></p>
<b>Reason:  </b><g:no_escape>${jvar_body}</g:no_escape>
<p></p>
<center><p>If you have questions about the implications of this event on your role, please contact your supervisor.</p>
<p></p>
<p>"Contact IT Support at XXX to report any other technical issues.</p></center>
<p></p>
</g:ui_form>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2019 05:52 AM
After some further messing around, I think I'm a step closer after following your lead BUT there are a few issues.
First issue is that I can't use that evaluate until after the record is saved. That is less than optimal as the whole reason for running this client-side is to show current changes,
Second issue in detail below.
Source field:
Here is the body.
This snippet:
<b>Reason alt:  </b><g:no_escape>${rec.u_body}</g:no_escape>
Produces:
Reason alt:
Here is thebody.
Note the space that for whatever reason just disappears.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2019 03:23 PM
Hi Shane,
Regarding your first issue:
If you want to get details from client side you can trigger glideform methods on the client script part of the UI Page or maybe within a script tag in the UI Page, which is set to execute on load. You can define "ID" on each HTML element where you want to update the content, then can use javascript functions to set those values. This will happen after the UI Page has rendered, i.e. <g:evaluate> has already been processed. So you can choose to update those values only if there is a change in the values which were fetched from Server side.
On your second issue:
Normally Jelly trims the whitespaces from the rendered result. You could use j2:whitespace tag to allow whitespaces to be rendered. Here's the documentation on using j2:whitespace
Whitespace
Normally, white space is removed by Jelly. To keep it, you must specify that it not be trimmed.
For example, the following keeps the space after the colon.
<j2:whitespace trim="false">${gs.getMessage('Did you mean')}: </j2:whitespace>
Try the following snippet:
<j2:whitespace><b>Reason alt: </b><g:no_escape>${rec.u_body}</g:no_escape></j2:whitespace>
Hope this helps!
Cheers,
Manish