Refresh a related list on field change

oharel
Kilo Sage

Hi guys,

Is there any way to refresh a related list when a field changes on the form?

For example: if I change the category on an incident form, I would like the related list category-articles to update, without saving the form first.

I tried an onChange client script with the following:

GlideList2.get(g_form.getTableName() + '.REL:31336814db772200e4257cbdae9619f4').setFilterAndRefresh('');

But I am not sure it can work without saving the form, which sort of makes this irrelevant.

Ideas?

harel

1 ACCEPTED SOLUTION

Mike Allen
Mega Sage

The wiki says that g_list is used in UI Context Menus and UI Actions:



GlideList2 (g list) - ServiceNow Wiki


View solution in original post

22 REPLIES 22

Hi John,



i try to avoid DOM, but checked it anyway.


I get:


onChange script error: TypeError: Cannot read property 'click' of null function



harel


Can you try



document.querySelector('div.related[tab_caption="Task SLAs"] span.breadcrumb_container a:last-of-type').click();



I replaced :last-child with :last-of-type, which makes this more specific.


Hi John,



onChange script error: TypeError: document.querySelector(...) is null function



My script is very simple- perhaps I am missing something in it:


function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue === '') {


          return;


  }



  //Type appropriate comment here, and begin script below


document.querySelector('div.related[tab_caption="incident lookup-KB"] span.breadcrumb_container a:last-of-type').click();


}



harel


Which release are you on?


BTW, tab_caption is case sensitive - it has be to capitalized exactly as in your Related List label (what you see on the form). Can you double check, please?