Confirmation Dialog Box using UI Page, OK Button will not work

Gary Martin
Mega Contributor

When cancelling a change, I am using a confirmation dialog box that pops up to enter reason and select OK.  When I enter the reason, select OK, nothing happens.  I xml'd the ui page and the Cancel change ui action from my personnel development instance because it works there.  I must be forgetting another piece like a client script or something?  Below is the information.  I just need to get the OK button to do something when I click it.  

UI Page: Change_confirm_cancel

HTML:

<?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:dialog_notes_ok_cancel
dialog_id="change_confirm_cancel"
textarea_id="change_confirm_reason_text"
textarea_label="${gs.getMessage('Reason')}"
textarea_label_title="${gs.getMessage('A reason is required to cancel this change')}"
textarea_name="change_confirm_reason_text"
textarea_onkeyup="enableButton()"
textarea_onchange="enableButton()"
textarea_style="height:auto; width: 100%; resize: vertical;"
textarea_title="${gs.getMessage('Enter the reason here')}"
ok=""
ok_action="cancelChangeRequest"
ok_id="change_confirm_ok_btn"
ok_title="${gs.getMessage('Cancel change request')}"
ok_type="button"
ok_style_class="btn btn-primary disabled"
cancel_title="${gs.getMessage('Close the dialog')}"
/>
</j:jelly>

UI Page Client script:

function cancelChangeRequest() {
var textArea = $("change_confirm_reason_text");
if (textArea)
moveToCancel(textArea.value.trim());
}

(function() {
$("change_confirm_reason_text").focus();
})();

Cancel Change UI Action:

find_real_file.png

UI Action Script:

var changeConfirmCancelDialog;

function loadConfirmDialog() {
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
changeConfirmCancelDialog = new dialogClass("change_confirm_cancel", false, 648, 250);
changeConfirmCancelDialog.setTitle(new GwtMessage().getMessage("Cancel Change Request"));
changeConfirmCancelDialog.render();
}

function moveToCancel(notes) {
var ga = new GlideAjax("ChangeRequestStateHandlerAjax");
ga.addParam("sysparm_name", "getStateValue");
ga.addParam("sysparm_state_name", "canceled");
ga.getXMLAnswer(function(stateValue) {
g_form.setValue("state", stateValue);
g_form.setValue("work_notes", notes);
changeConfirmCancelDialog.destroy();
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_canceled");
});
}

if (typeof window == 'undefined')
setRedirect();

function setRedirect() {
current.update();
action.setRedirectURL(current);
}

6 REPLIES 6

Sheryl Lyke2
Tera Guru

Thanks, Gary. I think one of my issues was I was using the gel function which I read sometimes doesn't work in a ui page. I replaced with getElementById. I'm using a reference field and not a text field so that may be different. Thanks for the response!

Naveen V1
Tera Contributor

Hi @Gary Martin. I have a requirement to add dropdown field in popup instead of multiline text within <g:dialog_notes_ok_cancel>. Can you tell how can we modify the script?