Pop Up confirmation message in UI action does not work for creating incident

Radhika1
Tera Contributor

Hi,

I have created a UI action 'Create Incident' on the HR case and it was working fine. Additionally, I wanted to add a pop-up confirmation message and clicking OK should let the user create an incident or else stay on the same form. But this code does not run and clicking on UI action is not creating any incident. Please have a look at the code I used below and help me understand what is wrong with it.

/****************************************************************************************************************?

function createInci() {
    var answer = confirm("Are you sure that you want to go ahead with creating an incident");
    if (answer == 'true') {
        gsftSubmit(null, g_form.getFormElement(), 'createInc');
    } else {
        return false;
    }
 
if (typeof window == 'undefined')
   resolveIncidentFunction();
function resolveIncidentFunction() {
    var gr = new GlideRecord('incident');
    gr.caller_id = current.opened_for;
    gr.short_description = current.short_description;
    gr.description = current.rich_description;
    var inc = gr.insert();
 
    GlideSysAttachment.copy('sn_hr_core_case', current.sys_id, 'incident', inc); //copies attachment if any can be commented if required.
       current.update();
 
    action.setRedirectURL(gr);
}
}
 
Please have a look at the screenshots of the UI action below:
 
Radhika1_0-1689152700477.png

 

 

Radhika1_1-1689152734659.png

 

 

Thanks in Advance,

RS

 

 

 

11 REPLIES 11

Harshad, it is 'true' after clicking ok. Screenshot below

Radhika1_2-1689323581567.png

 

 

 

After clicking ok comes the below one

Radhika1_1-1689323483521.png

 

In case anyone else comes across this post, the True part of the confirmation isn't running because the true is wrapped in single quotes, ex:

(answer == 'true')

 

It should be 

(answer == true)