Pass value from Client Script to UI Page

Shane5
Kilo Explorer

Hi,

I'm trying to pass a value from a Client Script to a UI Page, which I then want to use in the HTML. It's an onChange client script.

Here's what I currently have.
Client Script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}

	var contactUIMacro = new GlideModal('sn_customerservice_Actives Cases with Same Contact', false, 'modal-lg');
	contactUIMacro.setTitle('Active cases with same contact');
	var noOfCases = '5';
	contactUIMacro.setPreference('no_of_cases', '55');
	contactUIMacro.render();

}

UI Page HTML:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	
	<j:set var="jvar_no_of_cases" value="$(no_of_cases)" />

	<div class="form-group">
		<p>There are currently ${jvar_no_of_cases} active cases with the same contact.</p>
	</div>

</j:jelly>

I've tried several different methods to set the value before using it in my HTML, but nothing is working. Any help would be appreciated!

1 REPLY 1

Cuong Phan
Kilo Sage

Hi Shane,

 

Please add this to your UI page

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<g:evaluate var="jvar_num_case"
    expression="RP.getWindowProperties().get('no_of_cases')" />

	

	<div class="form-group">
		<p>There are currently ${jvar_num_case} active cases with the same contact.</p>
	</div>

</j:jelly>

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

Cuong Phan

DXC Consultant.

Regards,
Cuong Phan
ServiceNow Technical Lead