Pass value from Client Script to UI Page
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 05:47 AM
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!
Labels:
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2020 07:40 PM
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
Cuong Phan
ServiceNow Technical Lead