Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Updating record using UI page

Sarah31
Tera Contributor

Hello ,

I need my pop-up (UI page) to update the Closing Response Field  when I  click on Close Case (UI Action) and then have the case closed. 

The issue that I am getting is that when I click on my UI Action the pop-up is appearing but then a few seconds later it closes and doesn't go back to my record page. 

Note that my UI Action is already executing another script to close the case using a script include. 

I am not able to see what my error is. 

 

Action Name : closeCase

Onclick : validateReason()

Condition : (new global.StateFlow().validFlow(current, '81fa1d32dba688d06f1a325f9d9619d0', 'manual'));

 

Script : 

function validateReason() {
var case_id = g_form.getUniqueValue();
var dialog = new GlideDialogWindow("sn_customerservice_ci_close_case");
dialog.setTitle("Close Case");
dialog.setSize(600,300);
dialog.render();
 
 
 
  // Call the UI action and skip the 'onclick' function
  gsftSubmit(null, g_form.getFormElement(), 'closeCase'); //MUST call the 'Action name' set in this UI Action
}
 
// Code that runs without 'onclick'
// Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
  serverResolve();
 
// Server-side function
function serverResolve() {
  new global.StateFlow().processFlow(current, '81fa1d32dba688d06f1a325f9d9619d0', 'manual');
}

____________________________________________________________________

UI Page : 

HTML :

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<!-- Get the values from dialog preferences -->
<!-- Set up form fields and labels -->
 
<g:evaluate jelly="true">
var sysId = jelly.sysparm_sys_id;
var warningMsg1 = gs.getMessage('Please ensure code Closing response is validated below. Modify message if needed');
</g:evaluate>
 
<div style="line-height: 23px;"> 
 
 
 
<div>${warningMsg1}</div>
 
 
 
<div class="ta-wrapper">
<label for="closing_response">Closing Response</label>
<textarea id= "closing_response"  name= "closing_response" label = "Closing Response" onkeyup="" rows="20" size="" style="width: 100%;" wrap="soft"> Thank you for bringing this matter to our attention. This matter has been investigated. Due to privacy reasons, we cannot disclose the details of the investigation.</textarea>
 
</div>
 
</div>
 
<!--div align="right">
<input type="hidden" name="case_sys_id" value="${jvar_case_id}" />
<g:dialog_buttons_ok_cancel ok="return validateValue();" ok_type="submit" cancel_type="button" />
</div> -->
 
 
<div id = "dialog_buttons">
<div align="right">
<g:dialog_buttons_ok_cancel ok="return validateComments();" ok_type= "submit" cancel_type="button"/>
</div>
</div>
</g:ui_form>
</j:jelly>

 

Client Script : 

//Validating that field is not empty in dialog
function validateComments() {
var comments = gel("closing_response").value;
comments = trim(comments);
if (comments == "") {
alert("Please provide Closing response to close case.");
return false;
}
GlideDialogWindow.get().destroy();
return true;
}

 

 

Processing script :

var notes = request.getparameter('notes');
var grCase = new GlideRecord('sn_customerservice_corporate_investigation');
grCase.u_closing_response = closing_response;
grCase.get('u_closing_reponse');
grCase.update();

var urlOnStack = gs.getSession().getUrlOnStack();
response.sendRedirect(urlOnStack);

0 REPLIES 0