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

seems this could be the issue, I have seen this failing.

"answer == true"

can you please try this?

 

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.initialize();
    gr.caller_id = current.opened_for;
    gr.short_description = current.short_description;
    gr.description = current.rich_description;
    var inc = gr.insert();
 gs,log("POPUP" + inc );
    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);
}
}

 

Yes, this also did not let me create an incident. No log messages. 

 

what do you see from this?

do you get any popup?

 

function createInci() {
    var answer = confirm("Are you sure that you want to go ahead with creating an incident");
alert(answer);
alert(answer == true);

    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.initialize();
    gr.caller_id = current.opened_for;
    gr.short_description = current.short_description;
    gr.description = current.rich_description;
    var inc = gr.insert();
 gs,log("POPUP" + inc );
    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);
}
}

The confirmation box comes always. The below piece of code runs but not the server side one

 

function createInci() {
    var answer = confirm("Are you sure that you want to go ahead with creating an incident");
alert(answer);
alert(answer == true);

    if (answer == true) {
        gsftSubmit(null, g_form.getFormElement(), 'createInc');
    } else {
        return false;
    }

yes, but what values do you see in those alert boxes? true false after you select ok? Can you send screenshots?

 

Thanks

Harshad