Problem Cancel action button, replicate it to incident.

Community Alums
Not applicable
Spoiler
I have a requirement, that I need some help with. I need to create an action button in the incident form that follows the same modal principle as the ootb cancel action button for Problem. I need the same modal to be displayed while these actions should happen on the record:

State= Closed, Resolution code = Canceled (created that option) , and resolution notes/worknotes updated based on the input given on the canceled reason. (see attachment)

I already tried to code this based on what this ootb scripts:

UI script API name: ProblemModalUIHelpers
UI action name: Cancel 

Can you please help me find a solution for this?  

If you need more information please do not hesitate to ask.







8 REPLIES 8

Community Alums
Not applicable

Also, I have replaced the values for the code added to "ProblemModalUIHelpers".

 // Open the modal for incident cancelation
       this.openModal("incident_cancel_dialog_form_view", "Incident Cancel Dialog Form View", 850, formValues, "cancel_incident")

Community Alums
Not applicable

Also tried to update the script in the UI action to:

function onCancel() {
    if (g_form && g_form.mandatoryCheck()) {
        ScriptLoader.getScripts("ProblemModalUIHelpers.jsdbx", function() {
            ProblemModalUIHelpers.openIncidentCancelModal();
        });
    }
}

Community Alums
Not applicable

If anyone has some insights on this I would appreciate it a lot, as I still didn't find a full solution. 

Ramz
Mega Sage

Hi @Community Alums ,

There might be a lot to the code for ProblemModalUIHelpers as it is OOb. ServiceNow might have included codes in it which might not be accessible by us. Instead of replicating the same I found a workaround. 

1.Create a new View and configure form layout to include only those fields you want to show in the pop-up

2.Write a UI action and call the view to show as a pop-up

UI Action script:

 function testRecord() {
     var sysID = g_form.getUniqueValue(); // sys_id of the record you want to show

     var dialog = new GlideDialogForm('Testing modal', 'incident', finish);
     dialog.setSysID(sysID); //Pass in sys_id to edit existing record, 
     dialog.addParm('sysparm_view', 'cancel_view_for_incident_pop_up'); //Specify a form view
     dialog.setDialogHeight(600);
     dialog.render();

     function finish() {
         //set something here
     }
 }

Adjust the code to Add mandatory or set values or other requirement you want to doOutput.pngUi action.png

Please mark my answer correct/helpful if it resolved your query