GlideModal/UI Page help

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 08:25 PM
I have an onChange client script which performs a GlideAjax call, queries a knowledge article and returns the article (wiki) text. The script then opens a GlideDialog window:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var glideAjax = new GlideAjax('MyTaskUtilAjax');
glideAjax.addParam('sysparm_name', 'getScript');
glideAjax.addParam('sysparm_ci', newValue);
glideAjax.getXMLAnswer(getScript);
}
function getScript(response) {
if (response) {
var glideModal = new GlideModal('my_incident_triage');
glideModal.setTitle('Incident Triage');
glideModal.setPreference('sysparm_script', response);
glideModal.setPreference('sysparm_sysId', g_form.getUniqueValue());
glideModal.setPreference('sysparm_table', g_form.getTableName());
glideModal.setBackdropStatic(true);
glideModal.render();
}
}
I want to display the wiki text in the dialog window in the same format as it is stored in the wiki- namely, preserve the new lines:
What I am ending up with is this:
I have tried applying CSS to the HTML element (white-space: pre-wrap;), however that does not seem to have any effect on the text honouring the new lines.
I am now (almost) convinced when the text is called in the UI page, the newlines have been stripped out.
How should I approach this so I can preserve the newlines/formatting of the wiki text? Should I do the data query in the UI page instead? I am curious if extra whitespace and such is stripped out when passing data to the glidedialog/model 'setPreference()' method?
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 09:09 PM
Hi
Please refer this blog it might help you to render exact data in HTML format
https://community.servicenow.com/community?id=community_blog&sys_id=e0fc62a5dbd0dbc01dcaf3231f9619fd
Mark ✅ Correct if my answer solves your issue and also mark 👍 Helpful if you find my response worthy.
Thanks & Regards
Himanshu Dubey

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 06:14 AM
Thanks for your response; that's not quite what I am looking for, though. I'm not using HTML fields....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2020 09:03 AM