GlideModal/UI Page help

Community Alums
Not applicable

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:

find_real_file.png

 

What I am ending up with is this:

 find_real_file.png

 

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.

find_real_file.png

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!

3 REPLIES 3

Himanshu Dubey
Giga Guru

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

Community Alums
Not applicable

Thanks for your response; that's not quite what I am looking for, though. I'm not using HTML fields.... 

Community Alums
Not applicable

I was able to resolve this by passing the sysId of the ci to the ui page, and doing the query there:

find_real_file.png

Now it's formatted correctly:

find_real_file.png