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.

How to popup UI page using UI Action with input textbox to capture in Approver comments ?

Virendra K
Kilo Sage

Hi All,

My requirement is,

 

When I will "Reject" any approval, there should be a popup window with "Rejection Reason" textbox.

Once I entered rejection reason and hit on "OK" button then the given reason should get captured/update in Approval form's "Comments" field. 

 

Please help me.

 

Regards,

VIrendra

5 REPLIES 5

Gangadhar Ravi
Giga Sage

Please refer below article for what you are trying to achieve 

https://servicenowguru.com/system-ui_glidedialogwindow-advanced-popups-ui-pages/

Virendra K
Kilo Sage

I have added below code , but its getting updated to Change table, not in Approval table. why so? 

Approval table's "State and Comments" should get update.

 

UI Action:

VirendraKharka_0-1715673533634.png

Code in UI Action: 

var rejectConfirmDialog;
function loadConfirmDialog() {
    var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
    rejectConfirmDialog = new dialogClass("chg_reject_reason_approvers", false, 648, 250);
    rejectConfirmDialog.setTitle(new GwtMessage().getMessage("Reason"));
    rejectConfirmDialog.render();
}
function moveToCancel(notes) {
    g_form.setValue("state", 'rejected');
    g_form.setValue("comments", notes);
    rejectConfirmDialog.destroy();
    gsftSubmit(null, g_form.getFormElement(), "reject");

}

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

function setRedirect() {
    current.update();
    action.setRedirectURL(current);
}
 
UI Page : 
Name: chg_reject_reason_approvers
 
<?xml version="1.0" encoding="utf-8" ?HTML:>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <g:dialog_notes_ok_cancel
        dialog_id="chg_reject_reason_approvers"
        textarea_id="reject_reason_text"
        textarea_label="${gs.getMessage('Reason')}"
        textarea_label_title="${gs.getMessage('A reason is required to cancel this incident')}"
        textarea_name="reject_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="cancelincident"
        ok_id="incident"
        ok_title="${gs.getMessage('Reject Approval')}"
        ok_type="button"
        ok_style_class="btn btn-primary disabled"
        incident_title="${gs.getMessage('Close the dialog')}"
    />
</j:jelly>
 
Client script:
function cancelincident() {
    var textArea = $("reject_reason_text");
    if (textArea)
        moveToCancel(textArea.value.trim());
}
(function() {
    $("reject_reason_text").focus();
})();
 
 

 

Virendra K
Kilo Sage

Hi @Dr Atul G- LNG  seek your help to fix this.

 

Hi @Virendra K 

Thanks for tagging me, but I am not that expert in code. @AshishKM  any help.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************