Open form in new window?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2019 06:45 PM
Looking for a solution for the following scenario
- User clicks a link under related links.
- 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)
- 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 navigation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2019 08:32 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2019 08:58 PM
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:
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2019 10:28 AM
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
}