How to retrieve value on UI Page from setPreference client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2024 08:24 AM
I'm creating a pop-up window that will ultimately change certain details on the respective form.
I'm sending over the sys_id within the client script but I'm not sure how to retrieve that value to use it on the UI Pages client script.
Is this not the right way to retrieve the value?
Client script with Set Preference:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if(g_form.getValue('type') == 'no_conversion')
{
var dialog = new GlideDialogWindow("no_conversion_popup");
dialog.setSize(600,600);
dialog.setTitle("No Conversion Selected");
dialog.setPreference('sys_id', g_form.getUniqueValue()); //pass current object id
dialog.render(); //Open the dialog
}
}
UI Page Script:
function continueOK() {
alert("OK clicked");
GlideDialogWindow.get().destroy();
}
function continueCancel() {
var gdw = GlideDialogWindow.get(); // attempting to get the sys_id value
var sys_id = gdw.getPreference('sys_id'); // attempting to get the sys_id value
alert("Cancel clicked - sys id is: " + sys_id);
GlideDialogWindow.get().destroy();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2024 08:57 PM
Hi @MBarrott
To retire the sys_id in Page side you need to access like this
You need to make little bit change on Ui page code as below
HTML code :
<?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_sys_id" value="${RP.getWindowProperties().get('sys_id')}"/>
<input id="record_sys_id" type="hidden" value="${jvar_sys_id}" />
<div>
<h2>Are you sure you want to cancel this UAR?</h2>
<button id="yes_button" class="btn btn-danger" onclick="continueOK();">Yes</button>
<button id="no_button" class="btn btn-secondary" onclick="continueCancel();">No</button>
</div>
</j:jelly>
there is no change in Client script of Ui page
function continueOK() {
alert("OK clicked");
GlideDialogWindow.get().destroy();
}
function continueCancel() {
var gdw = GlideDialogWindow.get(); // attempting to get the sys_id value
var sys_id = gdw.getPreference('sys_id'); // attempting to get the sys_id value
alert("Cancel clicked - sys id is: " + sys_id);
GlideDialogWindow.get().destroy();
}
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."
Thanks,
Karanth