- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 06:09 AM
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
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 06:29 AM
The wiki says that g_list is used in UI Context Menus and UI Actions:
GlideList2 (g list) - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 06:29 AM
The wiki says that g_list is used in UI Context Menus and UI Actions:
GlideList2 (g list) - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 06:33 AM
Hi Harel,
Can you check on this. This could be helpful for you.
Reload a Form or Related list from a Client Script - ServiceNow Guru
GlideList2 (g list) - ServiceNow Wiki
Mark Correct if this solves your issue and also hit Like and 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
‎01-12-2017 02:12 PM
Thanks Ankur,
Already checked those...
I'm afraid Mike is right (that is, I'm afraid I can't do what I want, not that Mike is right...)
Thanks guys.
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 03:10 PM
If you don't mind venturing into the DOM, adding this line to onChange will refresh the Related List:
document.querySelector('div.related[tab_caption="Task SLAs"] span.breadcrumb_container a:last-of-type').click();
where "Task SLAs" in this example is the label for the Related List. It clicks on the last filter condition of the breadcrumb to make sure you apply and retain the entire filter.
Using GlideList2 like below works as well, but I noticed it filters only on the default filter condition (because we're not passing the filter as an argument), losing the rest of the breadcrumb in case you have multiple filter conditions:
GlideList2.get(g_form.getTableName() + '.task_sla.task').setFilterAndRefresh();
If you want to mimic the construct of the GlideList2 line above, you can use
document.querySelector('div[tab_list_name_raw="' + g_form.getTableName() + '.task_sla.task"] span.breadcrumb_container a:last-of-type').click();
EDIT: replaced :last-child with :last-of-type, which makes it more specific
Hope this helps.
Please feel free to connect, follow, mark helpful / answer, like, endorse.
John Chun, PhD PMP ![]() | ![]() |
Winner of November 2016 Members' Choice Award