UI Action to open in a new window.

Harry Campbell2
Mega Guru

Good Afternoon All, hope you are all well.

I'm hoping this will be a simple one. I have created a UI Action to create a new gliderecord, however this opens in the current window & I would either like it to open in a new window or to open in a popup. I dont want to navigate away from the current page basically. I would also like it to ignore any mandatory fields on the current page if that is possible.

The code I have at the moment is:

var inc = new GlideRecord("incident");

var sysID = inc.insert();

current.incident_id = sysID;

var mySysID = current.update();

gs.addInfoMessage("Incident " + inc.number + " created");

action.setRedirectURL(inc);

action.setReturnURL(current);

Any help would be greatly appreciated.

Many Thakns

Harry

2 REPLIES 2

rob_pastore
ServiceNow Employee
ServiceNow Employee

Combine your last 2 lines into 1:



action.setRedirectURL(current);


DrewW
Mega Sage
Mega Sage

Looks like your UI Action is meant to run server side.   You need to create a UI Action that runs on the client.



Here is a sample.



function addNewTicket(){


    var dialog = new GlideDialogForm('Create Child Ticket', 'ticket', setStatus);


    dialog.setSysID('-1'); //Pass in -1 to create a new record


    dialog.addParm('sysparm_view', 'access_admin'); //Specify a form view


    dialog.addParm('sysparm_form_only', 'true'); //Remove related lists


    dialog.addParm('sysparm_query', 'parent=' + g_form.getUniqueValue() + '^assignment_group=423fcc58c574300037e14928e64e7368'); //Remove related lists


    dialog.render(); //Open the dialog


   


    //Callback function executed from dialog submit


    function setStatus(action, sys_id, table, displayValue){


          if(action == "sysverb_insert"){


                g_form.setValue("request_state", "Pending Epic Security");


                g_form.setValue("u_resolution_details", "Updated access");


                g_form.submit();


          }


    }


}