Give a pop up once UI Action is clicked in SOW

Amey8
Tera Guru

I am working on problem management , we have a OOB UI Action 'Create Problem' on incident table. As soon as we click on it a problem record is created and saved.

My requirement is to show a pop up box first and when user clicks 'OK' then only proceed to create a problem.

I have modified the below code and it is working fine in the Default view. I want to configure the same for SERVICE OPERATIONS WORKSPACE , tried several things but its not working.

 

**

function ConfirmProblem(){
    var answer = confirm("This will create a problem ticket for this Incident. Are you sure to continue? ");
    if (answer == true) {
        gsftSubmit(null, g_form.getFormElement(), 'confirm_problem');
    } else {
        return false;
    }
}

if (typeof window == 'undefined') {
    var prob = new IncidentUtils().getProblemFromIncident(current);
    if (prob != undefined) {
        current.problem_id = prob.insert();
        if (current.state != IncidentState.RESOLVED) {
            current.state = IncidentState.ON_HOLD;
            if (current.isValidField("hold_reason"))
                current.hold_reason = IncidentState.AWAITING_PROBLEM;
        }
        if (GlidePluginManager.isActive("com.snc.best_practice.problem.madrid")) {
            var problemV2Util = new ProblemV2Util();
            problemV2Util.copyAttachments(current, prob);
            problemV2Util.copyAttachedKnowledge(current, prob);
        }
        current.update();
        gs.addInfoMessage(gs.getMessage("Problem {0} created", prob.number));
        action.setRedirectURL(prob);
        action.setReturnURL(current);
    } else {
        action.setRedirectURL(current);
    }
}

**

 

 

What should i write in Workspace Client script ?

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron

@Amey8 

yes you need to write that in workspace client script

The OOTB UI action is server side, I think you made it client + server

In workspace client script you will have to use prompt and then use GlideAjax

You will find lot of OOTB UI actions for that

Something like this

function onClick(g_form) {
    var prompt = "This will create a problem ticket for this Incident. Are you sure to continue?";

    var bConditionPassed = g_modal.confirm(prompt);
    if (bConditionPassed) {
        // use GlideAjax call here and put the above server side code in script include and pass the required parameters
    }
}

AnkurBawiskar_0-1745469905484.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

View solution in original post

5 REPLIES 5

Thanks. The code was creating the record without clicking the pop up actions , it worked with below code 

function onClick(g_form) {
    var prompt = getMessage("This will create a problem ticket for this Incident. Are you sure to continue? ");
    g_modal.confirm(prompt, function(confirmed) {
        if (confirmed) {
            g_form.submit('create_problem');
        }
    });

    return false;
}