How can you refresh a list view from a script

ryan_cox
Giga Contributor

Hey guys....

 

Not sure if I am doing something wrong here. I thought this would be simple.

 

I have a before Business Rule that is updating a value when another field changes. When I update the field from the list view, I have to click the breadcrumb to refresh the screen and see the change to the other field. Is there a way to refresh the list view from a script?

 

I tried g_list.refresh(); from an onCellEdit but that just locked up when I tried to change the value.

8 REPLIES 8

Slava Savitsky
Giga Sage

A possible workaround would be to use the split screen feature. When you update a record in the form pane, values of the cells in the list pane refresh automatically.


Dan_Berglin
Giga Expert

Hi,


Do like this example:



refreshAffectedServices();



function refreshAffectedServices(){


  var listId = g_form.getTableName() + '.task_cmdb_ci_service.task'; //Replace with the ID of your list


  if(typeof $(listId) != "undefined") {


        GlideList2.get(listId).setFilterAndRefresh('');


  }


}



The ID of the related list should be current_table_name.related_table_name.refrence_field_name.


andycary
Mega Contributor

I had this same issue where I wanted to refresh a related list after updating a record (without reloading the page).



I did this by using the following line in my script (UI Action):



g_list.refresh(1);



I found this by viewing the source code for the UI Context Menu called "Refresh List".


Gabor Monostori
Tera Contributor

Client Script - onCellEdit



function onCellEdit(sysIDs, table, oldValues, newValue, callback) {


      var saveAndClose = true;


     


      callback(saveAndClose);


     


      GlideList2.get("table_name").refresh();


}