The Zurich release has arrived! Interested in new features and functionalities? Click here for more

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






 

 

 

3 REPLIES 3

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

 

Thank you, sorry I didn't get back to you sooner, the g_aw method above is till opening a new window and not opening the form within the tab.  I have tried several methods with no luck so far, Is there another way to achieve opening the form in the form from a button on a specific tab that opens the form on a tab instead of a new window?

 

If the glide agent workspace method is opening it in a new browser tab then you may have something outside of ServiceNow doing it. The only other thought is that you may a separate onClick script that is opening the new browser tab. I would make sure you don't have multiple onClick scripts being triggered  and if that isn't the case then I don't know what may be the cause. 

Would need to evaluate the console and such via dev tools when you click the button to possibly track down the issue.