when a perticular ui action is clicked then how to pop up a text box

anupambose
Tera Contributor

when a perticular ui action is clicked then how to pop up a text box

3 REPLIES 3

Appanna M
Tera Guru

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can use something simple in JavaScript like this

AnuragTripathi_0-1711472988378.png

 

 

var person = prompt("Question:", "Sample Text");

 

-Anurag

Amit Pandey
Kilo Sage

Hi @anupambose 

 

I have created something similar for my use case. When case is canceled, it asks for a reason in a dialogue box. You can do similarly-

 

function confirmCancellation() {

    var gm = new GlideModal('convertToLabel');
    gm.setTitle('Reason For Cancelation');
    gm.renderWithContent('<div style="padding:15px"><p>Please write the reason for canceling this case.</p><p><textarea  id="taskCancellation" name= "cancellation" rows="2" cols="60"></textarea></p><div style="padding:5px;float:right"><button style="padding:5px;margin-right:10px" onclick="window.changeTaskAction(this.innerHTML,jQuery(\'#taskCancellation\').val())" class="btn btn-success">Don\'t Cancel</button><button  style="padding:5px" class="btn btn-danger" onclick="window.changeTaskAction(this.innerHTML,jQuery(\'#taskCancellation\').val())">Cancel Case</button></div></div>');

    window.changeTaskAction = function(thisButton, thisAction) {
        gm.destroy();
        if (thisButton == 'Cancel Case') {
            var userInput = thisAction;
            if (thisAction) {
                g_form.setValue('state', '7');
                g_form.setValue('close_notes', thisAction);
                g_form.setValue('active', 'false');

                var fields = g_form.getEditableFields();
                for (var x = 0; x < fields.length; x++) {
                    g_form.setMandatory(fields[x], false);
                }
            }
            gsftSubmit(null, g_form.getFormElement(), 'cancelCase');
        }
    };
    return false; //prevents the form from submitting when the dialog first loads
}
if (typeof window == 'undefined') {
    cancelThisCase();
}

function cancelThisCase() {
    current.state = '7';
    //current.active = 'false';
    current.closed_at = new GlideDateTime();
    current.setWorkflow(false);
    current.work_notes = 'Case cancelled by ' + gs.getUserName();
    current.update();
    action.setRedirectURL(current);