<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: UI Page g_form.save() doesn't commit changes in CSM forum</title>
    <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417692#M18639</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Please go through below link.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://hi.service-now.com/kb_view.do?sysparm_article=KB0743833"&gt;https://hi.service-now.com/kb_view.do?sysparm_article=KB0743833&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Mark it correct and helpful.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Bhagyashri Sorte.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Sep 2020 12:27:32 GMT</pubDate>
    <dc:creator>Bhagyashri Sort</dc:creator>
    <dc:date>2020-09-18T12:27:32Z</dc:date>
    <item>
      <title>UI Page g_form.save() doesn't commit changes</title>
      <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417688#M18635</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I am currently trying to&amp;nbsp;set&amp;nbsp;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to set the 'Clear code' on the work order task to the selected 'Clear code' value found in the form below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/14857iBDC6C5FDF9DAB34D/image-size/large?v=v2&amp;amp;px=999" srcset="/community/image/serverpage/image-id/14857iBDC6C5FDF9DAB34D/image-size/large?v=v2&amp;amp;px=999 1.0x" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/14859i22BDCF04E1D68CEA/image-size/large?v=v2&amp;amp;px=999" srcset="/community/image/serverpage/image-id/14859i22BDCF04E1D68CEA/image-size/large?v=v2&amp;amp;px=999 1.0x" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I have tried using both g_form.save() and&amp;nbsp;gsftSubmit(gel('sysverb_update_and_stay')) but no luck.&amp;nbsp;Appreciate any assistance.&lt;/P&gt;
&lt;P&gt;Here is&amp;nbsp;what I'm working with.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;UI Page HTML&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-markup"&gt;&lt;CODE&gt;&amp;lt;g:ui_form&amp;gt;
    &amp;lt;j:set var="task_id" value="${RP.getWindowProperties().get('sys_id')}" /&amp;gt;
    &amp;lt;input type="hidden" name="cancelled" id="cancelled" value="false" /&amp;gt;
    &amp;lt;input type="hidden" name="task_id" id="task_id" value="${RP.getWindowProperties().get('sys_id')}" /&amp;gt;
    &amp;lt;input type="hidden" name="state_flow" id="state_flow" value="${RP.getWindowProperties().get('state_flow_id')}" /&amp;gt;
    &amp;lt;j:set var="cancelled" value="false" /&amp;gt;
    &amp;lt;j:set var="jvar_work_notes" value="${RP.getWindowProperties().get('work_notes')}" /&amp;gt;
    &amp;lt;j:set var="jvar_dependent_value" value="${RP.getWindowProperties().get('dependent_value')}" /&amp;gt;
    &amp;lt;style&amp;gt;
    #task_close_incomplete .left {
        max-width: 60px;
    }

    #task_close_incomplete #yesno {
        width: 98%
    }

    HTML[data-doctype=true] #task_close_incomplete #yesno {
        width: 100%
    }
    &amp;lt;/style&amp;gt;
    &amp;lt;table id="task_close_incomplete" width="100%"&amp;gt;
        &amp;lt;colgroup&amp;gt;
            &amp;lt;col /&amp;gt;
            &amp;lt;col /&amp;gt;
        &amp;lt;/colgroup&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td class="left"&amp;gt;
                &amp;lt;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;"&amp;gt;I&amp;lt;/span&amp;gt;
                &amp;lt;label for="clear_code"&amp;gt;${gs.getMessage("Clear code")}&amp;lt;/label&amp;gt;
            &amp;lt;/td&amp;gt;
            &amp;lt;td align="right" style="padding: 0 0 4px 8px;"&amp;gt;
                &amp;lt;select name="clear_code" id="clear_code" class="form-control select2"&amp;gt;
                    &amp;lt;option /&amp;gt;
                    &amp;lt;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();" /&amp;gt;
                    &amp;lt;j2:while test="$[gr.next()]"&amp;gt;
                        &amp;lt;option value="$[gr.getValue('value')]"&amp;gt;$[gr.getValue('label')]&amp;lt;/option&amp;gt;
                    &amp;lt;/j2:while&amp;gt;
                &amp;lt;/select&amp;gt;
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td colspan="2" id="clear_code_error" style="display: none"&amp;gt;
                &amp;lt;img src='images/outputmsg_error.gifx' alt=''/&amp;gt;${gs.getMessage("Please provide a clear code")}
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    &amp;lt;/table&amp;gt;
&amp;lt;/g:ui_form&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;UI Page Client Script&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;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 &amp;lt; 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 &amp;lt; 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 &amp;lt; 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;
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Oct 2018 15:09:05 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417688#M18635</guid>
      <dc:creator>SS132314</dc:creator>
      <dc:date>2018-10-16T15:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: UI Page g_form.save() doesn't commit changes</title>
      <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417689#M18636</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;The user in below link faced similar issue have a look if it helps.&lt;/P&gt;
&lt;P&gt;https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=e1c08b65db98dbc01dcaf3231f96198d&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mark my ANSWER as CORRECT and HELPFUL if it helps.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 16:20:20 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417689#M18636</guid>
      <dc:creator>JerryJ071847183</dc:creator>
      <dc:date>2018-10-16T16:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: UI Page g_form.save() doesn't commit changes</title>
      <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417690#M18637</link>
      <description>&lt;P&gt;Unfortunately even though this resolves the issue around submitting the clear code field, it brings about another issue where&amp;nbsp;the work order task is not moved to the state of 'Closed incomplete'. I imagine the g_form.save() action is now abruptly ending any processing that happens in my processing script where a call is made to the appropriate 'sf_state_flow' table to correctly update the state of the WOT.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Processing Script&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE class="language-javascript"&gt;&lt;CODE&gt;if ('false' == cancelled) {
    var taskToClone = new GlideRecord("sm_task");
    if (taskToClone.get(task_id)) {
        var className = taskToClone.sys_class_name;
        taskToClone = new GlideRecord(className);
        taskToClone.get(task_id);
        var clonedTask;
        if (GlidePluginManager.isActive('com.snc.wm_questionnaire')) {
            var gr = new GlideRecord("sf_state_flow");
            gr.get(state_flow);
            taskToClone.state = gr.end_text;
            if (new FSMQuestionnaireHelper().pendingQuestionareExist(taskToClone)) {
                response.sendRedirect("sm_task.do?sys_id=" + taskToClone.sys_id);
                gs.addErrorMessage(gs.getMessage('Please complete mandatory questionnaires.'));
            } else {
                taskToClone = new GlideRecord(className);
                taskToClone.get(task_id);
                if (yesno == 'y') {
                    // Clone the current task
                    var clonedTask = new SMTask().cloneTask(taskToClone, true);
                    getWorkNote(clonedTask);
                }
                taskToClone.work_notes = work_notes_update;
                new global.StateFlow().processFlow(taskToClone, state_flow, 'manual');
                if (yesno == 'y') {
                    // redirect to the newly cloned task
                    response.sendRedirect("sm_task.do?sys_id=" + clonedTask.sys_id);
                    gs.addInfoMessage(gs.getMessage("Cloned from {0}", taskToClone.getValue('number')));
                } else {
                    response.sendRedirect("sm_task.do?sys_id=" + taskToClone.sys_id);
                }
            }
        } else {
            if (yesno == 'y') {
                // Clone the current task
                var clonedTask = new SMTask().cloneTask(taskToClone, true);
                getWorkNote(clonedTask);
            }
            taskToClone.work_notes = work_notes_update;
            new global.StateFlow().processFlow(taskToClone, state_flow, 'manual');
            if (yesno == 'y') {
                // redirect to the newly cloned task
                response.sendRedirect("sm_task.do?sys_id=" + clonedTask.sys_id);
                gs.addInfoMessage(gs.getMessage("Cloned from {0}", taskToClone.getValue('number')));
            } else
                response.sendRedirect("sm_task.do?sys_id=" + taskToClone.sys_id);
        }
    }
}

// ACN added - copy reason for follow up to cloned task
function getWorkNote(clone) {
    clone.work_notes = "Reason for incomplete closure of original task:\n" + work_notes_update;
    clone.update();
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Oct 2018 10:40:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417690#M18637</guid>
      <dc:creator>SS132314</dc:creator>
      <dc:date>2018-10-17T10:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: UI Page g_form.save() doesn't commit changes</title>
      <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417691#M18638</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the same problem,&lt;/P&gt;
&lt;P&gt;the manual changes made on the form before hitting the UI Action(which triggers UI page) are not saving to the database although we have the g_form.save() in the UI&amp;nbsp; Page client script.&lt;/P&gt;
&lt;P&gt;The processing script is working fine though.&lt;/P&gt;
&lt;P&gt;were you able to resolve this issue?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 12:16:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417691#M18638</guid>
      <dc:creator>shanmukhasai</dc:creator>
      <dc:date>2020-09-18T12:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: UI Page g_form.save() doesn't commit changes</title>
      <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417692#M18639</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Please go through below link.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://hi.service-now.com/kb_view.do?sysparm_article=KB0743833"&gt;https://hi.service-now.com/kb_view.do?sysparm_article=KB0743833&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Mark it correct and helpful.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Bhagyashri Sorte.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 12:27:32 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417692#M18639</guid>
      <dc:creator>Bhagyashri Sort</dc:creator>
      <dc:date>2020-09-18T12:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: UI Page g_form.save() doesn't commit changes</title>
      <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417693#M18640</link>
      <description>&lt;P&gt;Thank you for your reply,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried using all the 3, g_form.save(), g_form.submit() and&amp;nbsp;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 12:36:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/417693#M18640</guid>
      <dc:creator>shanmukhasai</dc:creator>
      <dc:date>2020-09-18T12:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: UI Page g_form.save() doesn't commit changes</title>
      <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/2734312#M35515</link>
      <description>&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2023 08:44:45 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/2734312#M35515</guid>
      <dc:creator>Ihor Kochetkov</dc:creator>
      <dc:date>2023-11-16T08:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: UI Page g_form.save() doesn't commit changes</title>
      <link>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/2999227#M39234</link>
      <description>&lt;P&gt;You saved my day! I confirm its an ACL issue&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2024 07:26:33 GMT</pubDate>
      <guid>https://www.servicenow.com/community/csm-forum/ui-page-g-form-save-doesn-t-commit-changes/m-p/2999227#M39234</guid>
      <dc:creator>Saif7</dc:creator>
      <dc:date>2024-07-25T07:26:33Z</dc:date>
    </item>
  </channel>
</rss>

