Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to pass variable from client script to HTML is ServiceNow UI page

nikhil_001
Tera Contributor

Hi All,

 

can anyone guide me how can we pass variable from client side to HTML in UI Pages?

 

Thanks

1 ACCEPTED SOLUTION

So, if the reason for why you want to get the contents of the <p/> element is to remove the HTML tags, that is not how it should be done.

You just need to enclose the phase 1 interpolation (${...}) within a <g:no_escape/> tag:

<p><g:no_escape>${ content }</g:no_escape></p>

 

View solution in original post

7 REPLIES 7

You're welcome! 🙂

Prince Arora
Tera Sage

@nikhil_001 ,

 

For example you html contains this tag:

 

<div id="myID"></div>

 

if you want to set something in HTML tag please use the dom operation.

 

document.getElementById('myID').innerHTML = '<h1>Please mark my answer correct</h1>';

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.

Markus Kraus
Kilo Sage

UI Action:

function onClick() {
	var dialog = new GlideModal('my_ui_page');
	dialog.setPreference('my_custom_variable', 'my_value');
	dialog.render();
}

UI Page (Client Script):

addLoadEvent(function() {
	var gdw = GlideDialogWindow.get();
	var myValue = gdw.getPreference('my_custom_variable');
	alert(myValue);
});