- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2016 08:50 AM
I'm trying to set a value in a choice list field (On Hold reason) on the incident form with the value I select from a UI Page.
I'm new to jelly and these kind of stuff so I assume it's something easy I'm missing here.
Everything works fine, except the new value is never saved.
I get the value and it's returned to the incident form.
The page reloads and the previous value is still present in the "On hold reason" field. Before it reloads I can see the new value there for a split second
This is what I'm working with
A Ui Action displaying a glide dialog window
function onHold2(){
var gdw = new GlideDialogWindow('on_hold_reason');
gdw.setTitle('Chose an On hold reason');
gdw.setSize(400,300);
gdw.setPreference('title', 'A New Title');
gdw.render();
}
My UI Page looks like this
<?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:ui_form>
<g:ui_choicelist name='HoldReason' table='incident' field='hold_reason' />
<br />
<br />
<g:dialog_buttons_ok_cancel ok="return updateOnHold()"/>
</g:ui_form>
</j:jelly>
Client script on the UI Page
function updateOnHold() {
//Gets called if the 'OK' dialog button is clicked
GlideDialogWindow.get().destroy(); //Close the dialog window
var reason = gel('HoldReason').value;
g_form.setValue('hold_reason', reason); //Set 'On Hold Reason' field with the chosen reason
g_form.save();
}
Processing script on UI Page
// redirect back
var urlOnStack = GlideSession.get().getStack().bottom();
response.sendRedirect(urlOnStack);
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2016 09:17 AM
We've found out what is causing the value not to be saved, it's the g:ui_form tag in the UI Page, if we remove them everything works fine.
No idea why it's like that, but in some way it seems like the g:ui_form does a reload or save the previous value when you perss the OK button.
The code we are using now is
UI ACTION
function onHold2(){
var d = new GlideModal('on_hold_reason', false);
d.setTitle('Chose an On hold reason');
d.setPreference('title', 'A New Title');
d.setSize(400,300);
d.render();
}
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:ui_choicelist name='HoldReason' table='incident' field='hold_reason' />
<br />
<br />
<g:dialog_buttons_ok_cancel ok="return updateOnHold()"/>
</j:jelly>
UI PAGE Client Script
function updateOnHold() {
var reason = gel('HoldReason').value;
g_form.setValue('hold_reason', reason);//Set 'On Hold Reason' field with the chosen reason
g_form.save();
GlideDialogWindow.get().destroy(); //Close the dialog window
return true;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2016 01:21 AM
I've tried without it but with the same outcome.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2016 01:30 AM
Try
var reason = gel('HoldReason').value;
g_form.setValue('hold_reason', reason); //Set 'On Hold Reason' field with the chosen reason
GlideDialogWindow.get().destroy(); //Close the dialog window
g_form.save();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2016 01:39 AM
Still same issue, it set the new value but never saves it.
Is there some issue with the UI Page and the use og g:ui_choicelist?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2016 01:44 AM
If you use the below 3 lines, does it sets the value to the form?
var reason = gel('HoldReason').value;
g_form.setValue('hold_reason', reason); //Set 'On Hold Reason' field with the chosen reason
GlideDialogWindow.get().destroy();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2016 01:48 AM
Yes, I can see that the new value is set, but when the page is reloaded the old value is displaying again.