Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to create custom dialog box & call it from UI Script?

Ankita Kolhe
Tera Contributor

Hi Community,

 

I have a requirement to create a custom pop up box with a title and two buttons named as 'Confirm' and 'Cancel' .

So when user clicks on 'Close Task' UI Action, this pop up should come and if user selects 'confirm', the state should move to closed complete & if user selects 'cance', the state remains as it is.

 

Below is the UI Action & UI page  created for the same:-

 

AnkitaKolhe_0-1685951839764.png

 

script:-

 

//for pass email address 
//added by jaylin 
function closeTask() {
    if (g_form.getValue('assigned_to')) {
//var isConfirmed=confirm(getMessage('hi'));
//alert(isConfirmed);
//if(isConfirmed)
        addEmailsAddress();
    } else {
        g_form.setMandatory('assigned_to', true);
 
    }
    
   // addEmailsAddress();
    //Call the UI Action and skip the 'onclick' function
    //gsftSubmit(null, g_form.getFormElement(), 'close_sc_task');
 
}
 
function addEmailsAddress() {
    var gr_request = new GlideRecord('sc_req_item');
    gr_request.addQuery('sys_id', g_form.getValue('request_item'));
    gr_request.query();
    if (gr_request.next()) {
 
        if (gr_request.cat_item == '1e9fbf11dbd28910fcf5a51fd396198b' && g_form.getValue('short_description').indexOf('Email Account') != -1) {
            setVariablesEmailsAddress(gr_request);
        } else if (gr_request.cat_item == '4799a9d11b2609105f62ba23164bcbce' && g_form.getValue('short_description').indexOf('Email Account') != -1) {
            setVariablesEmailsAddress(gr_request);
        } else {
            updateTask();
action.setRedirectURL(current);
 
        }
 
    }
    
}
 
function updateTask() {
alert('inside update');
var gm = new GlideModal("test");
        //Sets the dialog title
        //gm.setTitle('Show title');     
        gm.setWidth(550);
        //Opens the dialog
        var test=gm.render(); 
alert('test :'+test);
 if(test){
    g_form.setValue('state', 3);
    gsftSubmit(null, g_form.getFormElement(), 'close_sc_task_override');
//sftSubmit(null, g_form.getFormElement(), 'sysverb_update');
}
}
 
 
UI Page:-
AnkitaKolhe_1-1685952004027.png

 

Issue:- after clicking on Close Task UI Action, the custom dialog is showing up but the page gets loaded again.

 

Please help me on this.

 

Thanks,

Ankita

0 REPLIES 0