Declarative Action to Open Form

Annette Kitzmil
Tera Guru

Hello,

 

I have a scoped app that has a tab where I created a declarative action as a client script.  I then added the script below in order to open a form.  The issue is that it not only opens the form with a tab next to the case, but I am also opening up a new browser/window tab.  I only want the form to open a new tab, not another window.  I have tried many variations for opening this where some work and some don't.  Can anyone give me some direction please?

 

Also, this form that is opening will need most of the fields prefilled from the parent table, recommendations on the best way to accomplish this would be appreciated.

 

AnnetteKitzmil_0-1757010912276.png

 

function onClick() {
   
    var parentSysId = g_form.getUniqueValue(); // sys_id of the parent record
   
    //alert("Create Infraction button clicked!");
    var infractionNumber = g_form.getValue('number'); //set the caseNumber field
    var instanceName = g_form.getValue('instance_name');

    //url += '?parentRecord=' + encodeURIComponent(parentSysId);
    open(url, '');  

}
 
Thank you,
Annette






 

 

 

1 REPLY 1

John Gilmore
Giga Guru

It looks like you are in Workspace so GlideAgentWorkspace should be available in your instance.

Rather than generating the link the way you are you could use g_aw.openRecord('table name', 'record sys_id') to achieve this.

 

Using this method replace 'table name' with the table and pass the sys_id as -1. This will open the form in only a workspace tab.

I believe you should be able to pass the third parameter "params" to prefill fields on the form.

"params": {
  "readOnlyForm": Boolean;
  "defaultTab": "String";
  "hideDetails": Boolean
}


Documentation on the GlideAgentWorkspace: https://www.servicenow.com/docs/bundle/zurich-api-reference/page/app-store/dev_portal/API_reference/...