open list view of computer table in popup window

Shivani29
Mega Guru

Hi All,

 

There is a requirement, where I need to create a UI Action in computer table form which when clicked should show the list of devices from computer table itself which are allocated to the user who is selected in assigned to field in a popup window. I am able to get the list but it is getting open in new tab instead of pop up window. Below is the script:

 

function executeAction() {
    var userSysId = g_form.getValue('assigned_to');
    if (!userSysId) {
        alert('Assigned to field is empty.');
        return;
    }
    var url = new GlideURL('cmdb_ci_computer_list.do');
    url.addParam('sysparm_query', 'assigned_to=' + userSysId);
    g_navigation.openPopup(url.getURL());
}
 
I need some assistance on this.
 
Regards,
Shivani
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Shivani29 

you are using g_navigation and it will open new tab and not popup window

for popup window you need to use GlideDialogWindow

try this

function executeAction() {
    var userSysId = g_form.getValue('assigned_to');
    if (!userSysId) {
        alert('Assigned to field is empty.');
        return;
    }

    var w = new GlideDialogWindow('show_list');
    w.setTitle('Computer List');
    w.setPreference('table', 'cmdb_ci_computer_list');
    w.setPreference('sysparm_view', 'default');
    //Set the query for the list
    var query = 'assigned_to=' + userSysId;
    w.setPreference('sysparm_query', query);
    //Open the popup
    w.render();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Shivani29 

you are using g_navigation and it will open new tab and not popup window

for popup window you need to use GlideDialogWindow

try this

function executeAction() {
    var userSysId = g_form.getValue('assigned_to');
    if (!userSysId) {
        alert('Assigned to field is empty.');
        return;
    }

    var w = new GlideDialogWindow('show_list');
    w.setTitle('Computer List');
    w.setPreference('table', 'cmdb_ci_computer_list');
    w.setPreference('sysparm_view', 'default');
    //Set the query for the list
    var query = 'assigned_to=' + userSysId;
    w.setPreference('sysparm_query', query);
    //Open the popup
    w.render();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Shivani29 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi Ankur,

 

Thanks for highlighting the mistake. It is now working as expected.

 

Regards,

Shivani