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

Michael Fry1
Kilo Patron

Your code looks fine. When the dialog box first opens, i assume the OK button is greyed out. Then you enter comments, and nothing happens?

Gary Martin
Mega Contributor

Yes,

The button is grayed out.  However, when you enter text in the box, it is no longer grayed out.  You select OK and nothing happens.

It does work in my personnel development instance however.

No Text:

find_real_file.png

 

With Text:

find_real_file.png

 

Did you ever figure this out? I'm having a similar issue

Gary Martin
Mega Contributor

I did.  If I remember right, it was the order of execution in the script.  I will provide what I did and hopefully you can make sense of it.  See attached.  Please let me know if you get it to work!

Thanks