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
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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

Shree_G
Kilo Sage

@Amey8 ,

 

Please follow similar post below:

 

https://www.servicenow.com/community/now-platform-forum/workspace-experience-ui-action-with-g-modal-...

 

 


If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Amey8 

I believe I also shared a working solution.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Amey8 

I believe I also shared a working solution.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Shree_G
Kilo Sage

@Amey8 ,

 

Please follow similar post below:

 

https://www.servicenow.com/community/now-platform-forum/workspace-experience-ui-action-with-g-modal-...

 

 


If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.