How to refresh list view using refresh method

johannes5
Giga Expert

Hi ServiceNow Community Developers

I am trying to refresh a list view on a homepage using a UI action that has the refresh method however it's not working, instead it throws the following error on the browser console:

Error running context menu 'Perform Technical Assessment Task': TypeError: Cannot read property 'refresh' of undefined

Here is the code I have in my UI action:

function performTechAssessment() {

      nowRefresh(g_list.getTableName());

}

function nowRefresh(id) {

alert ("inside refresh method " + id);

      GlideList2.get(id).refresh();

}

Would you please advise as to what it is that I am doing wrong here.

Thanks

Johannes

1 ACCEPTED SOLUTION

Hi Guys,



A colleague of mine helped me to figure this out



here is the correct code that worked and refreshed my list view as expected:



function nowRefreshTheList() {


var w = top.gsft_main || top; //support for both having frame(navigator) and no frames


w.location.reload();


}


View solution in original post

4 REPLIES 4

purbalipc
Tera Expert

Hi Guys,



A colleague of mine helped me to figure this out



here is the correct code that worked and refreshed my list view as expected:



function nowRefreshTheList() {


var w = top.gsft_main || top; //support for both having frame(navigator) and no frames


w.location.reload();


}


Vikram3
Giga Guru

Marco Moro
Tera Guru

If someone is looking for a solution on how to retrieve the current table name on a list view without using DOM:

function refreshList() {
	GlideList2.get(Object.keys(GlideLists2)[0]).refresh(); 
}