- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2017 09:47 AM
I am trying to use the <g:no_escape> tag to stop escaping a variable that has HTML. It is not working and I can not figure out why. UI Page code is below. Thanks for any help.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!-- ek_techalert_view UI Page by JPisello/EKC, 2013-02-APR -->
<style type="text/css">
a {
color: blue;
text-decoration: underline;
}
img {
visibility: visible;
display: inline;
}
table {
white-space: normal;
width: 80%;
border-style: solid;
border-width: 2px;
border-color: #000000;
}
tr.gray{
background-color: #C0C0C0;
}
td.field {
width: 25%;
text-align: right;
padding-right: 10px;
font-weight: bold;
}
td.info {
text-align: left;
padding-left: 5px;
}
</style>
<head>
<br/>
<g2:evaluate var="jvar_link" jelly="true">
var id = RP.getWindowProperties().get('id');
//var id = 'eb8439590f19f200c1a16ab8b1050eac';
var number = '';
var grOut = new GlideRecord('incident');
grOut.get(id);
grOut.next();
var link = grOut.getLink(true);
link;
</g2:evaluate>
<!-- Get the Latest Updates into an array for later processing -->
<g2:evaluate var="jvar_updates" object="true">
var upd = grOut.work_notes.getJournalEntry(-1); //gets all journal entries as a string delimited by '\n\n'
upd = upd.replace(/\[code\]/g, "");
upd = upd.replace(/\[\/code\]/g, "");
var na = upd.split('\n'); //convert the updates to an array of strings
na; //return the array to the jvar_updates variable for use in the table below
</g2:evaluate>
</head>
<body>
<j2:whitespace trim="false">
<center>
<table>
<tr valign="middle" style="background-color: #f3b20b;">
<td colspan="2" align="center" style="font-size: 18;">Work Notes</td>
</tr>
<tr>
<td class="info">
<j2:if test="$[jvar_updates.length gt 0]"> <!-- the array contained elements -->
<j2:forEach var="jvar_upd" items="$[jvar_updates]"> <!-- loop through the array of updates -->
<g:no_escape>$[jvar_upd]</g:no_escape>
<br> </br>
</j2:forEach> <!-- loop through the array of updates -->
</j2:if> <!-- the array contained elements -->
<script>
</script>
</td>
</tr>
</table>
</center>
</j2:whitespace>
</body>
</j:jelly>
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 09:05 AM
I figured it out. There is nothing wrong with the last code I posted. UI Pages do not render the same if they are invoked using GlideDialogWindow. When you use GlideDialogWindow escaped HTML is treated as XML.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2017 09:50 AM
Hello Gregory,
Please refer
http://wiki.servicenow.com/index.php?title=How_to_Escape_in_Jelly#Escaping_Types
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2017 09:55 AM
Thanks Pradeep, I have gone over that document and every single document relating to escaping jelly I could find and I still can not figure out why my code does not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2017 02:44 PM
I simplified my UI page and now it appears that it is not escaping the HTML, but I get errors about end tags missing. It's as if it is being interpreted as XML instead of HTML. Here is my new 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">
<!-- Get the Latest Updates into an array for later processing -->
<g:evaluate>
var id = RP.getWindowProperties().get('id');
//var id = 'eb8439590f19f200c1a16ab8b1050eac';
var grOut = new GlideRecord('incident');
grOut.get(id);
grOut.next();
var docType = '<!DOCTYPE HTML>';
var upd = grOut.work_notes.getJournalEntry(-1); //gets all journal entries as a string delimited by '\n\n'
//upd = upd.replace(/\[code\]/g, "");
//upd = upd.replace(/\[\/code\]/g, "");
//upd;
</g:evaluate>
<g:no_escape>${HTML:upd}</g:no_escape>
<br> </br>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2017 09:05 AM
I figured it out. There is nothing wrong with the last code I posted. UI Pages do not render the same if they are invoked using GlideDialogWindow. When you use GlideDialogWindow escaped HTML is treated as XML.