Unable to render HTML properly in GlideModal, only escaped HTML is being displayed in UI Page popup. I have tried passing text with regular tags (unescaped) and the escaped version of the same text (<). Neither will display properly.

Tyler18
Tera Contributor

No matter how I format my message string, this is not the modal is displayed:

(image attached)

Code from UI Action: (tried formatting the message these 3 ways)

var message = '\<p\>\<span style=\"color: #ff0000;\"\>WARNING:\</span\> The actual start date/time is before the CAB approved start date/time. If this is not an error, the change implementer or manager must call the Command Center etc etc\</p\>';

var message1 = '<p><span style="color: #ff0000;">WARNING:</span> The actual start date/time is before the CAB approved start date/time. If this is not an error, the change implementer or manager must call the Command Center foo barr</p>';

var message2 = '&lt;p&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;WARNING:&lt;/span&gt; The actual start date/time is before the CAB approved start date/time. If this is not an error, the change implementer or manager must call the Command Center yata yata &lt;/p&gt;'

var dialog = new GlideModal("glide_confirm_standard", true, 450);
dialog.setTitle(new GwtMessage().getMessage('Confirmation'));
dialog.setPreference("title", message);
dialog.setPreference("warning", "true");
dialog.setPreference("onPromptComplete", doComplete);
dialog.setPreference("onPromptCancel", doCancel);
dialog.render();


UI Page: glide_confirm_standard

<g:ui_form onsubmit="return invokePromptCallBack('ok');">
	<g2:evaluate>
		var title = "${RP.getWindowProperties().get('title')}";
		title =  new GlideStringUtil().unEscapeHTML(title);
		var warning = "${RP.getWindowProperties().get('warning')}";
		warning =  new GlideStringUtil().unEscapeHTML(warning);
	</g2:evaluate>
	<table border="0" width="100%">
		<tr>
			<td nowrap="true" style="vertical-align:top;">
				<j2:switch on="$[warning]">
					<j2:case value="true">
					<i id="image_dialog" class="dialog_left_icon dialog_left_icon_warn icon-alert-triangle"/>
					</j2:case>
					<j2:default>
					<i id="image_dialog" class="dialog_left_icon dialog_left_icon_confirm icon-check-circle"/>
					</j2:default>
				</j2:switch>
			</td>
			<td>
				<table border="0" width="100%">
					<tr>
						<td class="dialog_content">$[title]</td>
					</tr>
					<tr class="dialog_buttons_row">
						<td class="dialog_buttons">
						<g:dialog_buttons_ok_cancel ok="invokePromptCallBack('ok');" ok_type="button" cancel="invokePromptCallBack('cancel')" cancel_type="button"/>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</g:ui_form>
1 ACCEPTED SOLUTION

Vasantharajan N
Giga Sage
Giga Sage

Please refer to the link below

https://community.servicenow.com/community?id=community_blog&sys_id=211361f8dbac5d505205e6be13961929


Thanks & Regards,
Vasanth

View solution in original post

1 REPLY 1

Vasantharajan N
Giga Sage
Giga Sage

Please refer to the link below

https://community.servicenow.com/community?id=community_blog&sys_id=211361f8dbac5d505205e6be13961929


Thanks & Regards,
Vasanth