Open Incident from UI Action with Parameters

nannette
Mega Contributor

I would like to create an Incident from a UI Action and populate two fields on the incident.

I have this code but it doesn't respond.   I have also used the GlideDilogWindow and but I can't seem to pass the values to the Incident form

function redirectToIncident()

{

     

      var uniqueid = current.u_caller_unique_id;

      var sysId = current.sys_id;

        var url = new GlideURL("incident.do");

              url.addParam("sysparm_caller_id", sysId);

              url.addParam("sysparm_u_caller_unique_id", uniqueid);

          var w = getTopWindow();

              w.popupOpenFocus(url.getURL(), '_blank', false, false);

     

     

      }

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

There are several ways to do this, what you're doing is a separate popup rather than a redirect.   If you want to redirect you can look at the 'Create Problem' UI action for an example in the system.   If you want to adjust your code so that you get a popup you could change it to something like this that uses 'sysparm_query' to populate field values as shown here...



Populating Default Values with a URL or Module - ServiceNow Guru



function redirectToIncident(){


    //Client-side get record sys_id


    var sysID = g_form.getUniqueValue();



    //Base URL for creating a new incident record and populating fields via 'sysparm_query' parameter


    var url = '/incident.do?sys_id=-1&sysparm_query=';



    //Query parameter for populating fields on the incident form.   Adjust this as needed.


    var urlParams = 'caller_id=' + sysID



    //Pop up window


    var w = getTopWindow();


    w.popupOpenFocus(url + urlParams, '_blank', false, false);


}


View solution in original post

10 REPLIES 10

Mark,



you are correct it open the window once i added the quotes.



Thanks,


Nannette