UI Page g_form.save() doesn't commit changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2018 08:09 AM
Hi,
I am currently trying to set a choice field on the work order task to an option selected by the user in a GlideDialogWindow which is generated from a UI page.
I need to set the 'Clear code' on the work order task to the selected 'Clear code' value found in the form below.
However the work order task is set to 'Closed incomplete' successfully without committing the changes to the 'Clear code' value even though I can see the field being set before the work order task is updated and refreshed.
I have tried using both g_form.save() and gsftSubmit(gel('sysverb_update_and_stay')) but no luck. Appreciate any assistance.
Here is what I'm working with.
UI Page HTML
<g:ui_form>
<j:set var="task_id" value="${RP.getWindowProperties().get('sys_id')}" />
<input type="hidden" name="cancelled" id="cancelled" value="false" />
<input type="hidden" name="task_id" id="task_id" value="${RP.getWindowProperties().get('sys_id')}" />
<input type="hidden" name="state_flow" id="state_flow" value="${RP.getWindowProperties().get('state_flow_id')}" />
<j:set var="cancelled" value="false" />
<j:set var="jvar_work_notes" value="${RP.getWindowProperties().get('work_notes')}" />
<j:set var="jvar_dependent_value" value="${RP.getWindowProperties().get('dependent_value')}" />
<style>
#task_close_incomplete .left {
max-width: 60px;
}
#task_close_incomplete #yesno {
width: 98%
}
HTML[data-doctype=true] #task_close_incomplete #yesno {
width: 100%
}
</style>
<table id="task_close_incomplete" width="100%">
<colgroup>
<col />
<col />
</colgroup>
<tr>
<td class="left">
<span title="${gs.getMessage('Mandatory - must be populated before Submit')}" mandatory="true" oclass="mandatory" style="background-color:#C00;color:#C00;margin-right:3px;margin-left:1px;">I</span>
<label for="clear_code">${gs.getMessage("Clear code")}</label>
</td>
<td align="right" style="padding: 0 0 4px 8px;">
<select name="clear_code" id="clear_code" class="form-control select2">
<option />
<g2:evaluate var="jvar_item" expression="var gr = new GlideRecord('sys_choice');gr.addQuery('name', 'wm_task');gr.addQuery('element', 'u_clear_code');gr.addQuery('dependent_value', '${jvar_dependent_value}');gr.addQuery('inactive', 'false');gr.query();" />
<j2:while test="$[gr.next()]">
<option value="$[gr.getValue('value')]">$[gr.getValue('label')]</option>
</j2:while>
</select>
</td>
</tr>
<tr>
<td colspan="2" id="clear_code_error" style="display: none">
<img src='images/outputmsg_error.gifx' alt=''/>${gs.getMessage("Please provide a clear code")}
</td>
</tr>
</table>
</g:ui_form>
UI Page Client Script
function submitCancel(){
var c = gel('cancelled');
c.value = "true";
GlideDialogWindow.get().destroy();
return false;
}
function submitChanges() {
var taskId = gel('task_id').value;
var selection = gel('yesno').value;
if (selection.length < 1) {
document.getElementById('yesno_error').style.backgroundColor="#FFEBE8";
document.getElementById('yesno_error').style.display="block";
return false;
}
else{
document.getElementById('yesno_error').style.display="none";
}
var clearCode = gel('clear_code').value;
if (clearCode.length < 1) {
document.getElementById('clear_code_error').style.backgroundColor="#FFEBE8";
document.getElementById('clear_code_error').style.display="block";
return false;
}
else{
document.getElementById('clear_code_error').style.display="none";
g_form.setValue('u_clear_code', clearCode); }
var notes = gel('work_notes_update').value.replace(/^\s+|\s+$/g,''); // trim
if (notes.length < 1) {
document.getElementById('work_notes_error').style.backgroundColor="#FFEBE8";
document.getElementById('work_notes_error').style.display="block";
return false;
}
else{
document.getElementById('work_notes_error').style.display="none";
}
g_form.clearValue("work_notes");
g_form.save();
GlideAjax.disableSessionMessages();
return true;
}
- Labels:
-
Field Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2020 05:36 AM
Thank you for your reply,
I tried using all the 3, g_form.save(), g_form.submit() and gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay') ,but still it does not update the values entered on the form after the processing script in the UI Page gets executed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 12:44 AM
I had the same and resolved it with adding Write ACL on field State (which I'm changing in my client script) which allows to change the state for end user who clicks this button. So first make sure that this user can change the status manually on the form, if no - it's ACL issue and button will not work until you fix ACL.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 12:26 AM
You saved my day! I confirm its an ACL issue
Thanks