Open form in new window?

Edwin Fuller
Tera Guru

Looking for a solution for the following scenario 

  1. User clicks a link under related links.
  2. A new window pops up similar to how an dialog box would pop up. (It shouldn't redirect to another page, tab, or window. It should keep the current window up and simply display the form of the table we are inserting into on top of the current page but smaller so that it doesn't take up the entire window)
  3. User reviews the details and clicks save to create the new record.

This is the current script I am using within an UI Action. Currently, it opens in an new tab which is the behavior I don't want.

function createNewAnnouncement(){

var name = g_form.getValue('short_description');
var title = g_form.getValue('short_description');
var task = g_form.getUniqueValue();
var begin = g_form.getValue('begin');
var summary = "We are aware of the issue and are taking steps to correct it as soon as possible";

//Open Announcemnet Record and populate field from Event
window.open('/nav_to.do?uri=announcement.do?sys_id=-1%26sysparm_query=name=' + name + '^title=' + title + '^u_task=' + task + '^summary=' + summary + '^from=' + begin, '_blank');

 

Here is an mock up of what I'm looking for. Preferably the window would be much smaller and only display the form and not the left hand navigationfind_real_file.png 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Edwin,

If you want it to open in same tab then use this; i.e. _self instead of _blank

window.open('/nav_to.do?uri=announcement.do?sys_id=-1%26sysparm_query=name=' + name + '^title=' + title + '^u_task=' + task + '^summary=' + summary + '^from=' + begin, '_self');

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Alikutty A
Tera Sage

Hi Edwin,

You should be using a GlideDailogWindow instead of a popup. The window.open() would open your record in a new or same browser window.

Please refer to these links and you could setup one:

https://docs.servicenow.com/bundle/newyork-application-development/page/app-store/dev_portal/API_ref...

https://community.servicenow.com/community?id=community_question&sys_id=7d0a8369db5cdbc01dcaf3231f96...

https://community.servicenow.com/community?id=community_question&sys_id=644d8ba9db9cdbc01dcaf3231f96...

Thanks!

Thanks I was able to get it working with an UI Action

 

function createNewAnnouncement(){

var tableName = 'announcement';
var sysID = -1;
var shortdesc = g_form.getValue('short_description');
var task = g_form.getUniqueValue();
var begin = g_form.getValue('begin');
var summary = "We are aware of the issue and are taking steps to correct it as soon as possible";

//Create and open the dialog form
var dialog = new GlideDialogForm('Create New Announcement', tableName); // Provide dialog title and table name
dialog.setSysID(sysID); // Pass in sys_id to edit existing record, -1 to create new record
dialog.setSize(false,100);
dialog.addParm('sysparm_query','name=' + shortdesc + '^title=' + shortdesc + '^u_task=' + task + '^from=' + begin + '^summary=' + summary );
dialog.render(); //Open the dialog
}