- 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-13-2017 12:51 PM
Helsinki.
The label was copy-pasted...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 01:23 PM
I tested it in Helsinki using the below Client Script with the "Task SLAs" Related List (please rename it to your RL label) and it worked fine, as demonstrated by the screenshots below (the screenshots don't prove the RL was refreshed, but it shows the selector successfully selected the last filter condition - when this runs on yours, you'll be able to confirm the RL indeed gets refreshed):
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}//Type appropriate comment here, and begin script below
var filter = document.querySelector('div.related[tab_caption="Task SLAs"] span.breadcrumb_container a:last-of-type');
alert(filter.outerHTML);
filter.click();
}
If this still fails to run on yours, you can reduce the filter variable gradually to see where it fails, like
var filter = document.querySelector('div.related[tab_caption="Task SLAs"] span.breadcrumb_container');
var filter = document.querySelector('div.related[tab_caption="Task SLAs"] span.breadcrumb');
var filter = document.querySelector('div.related[tab_caption="Task SLAs"]');
Sorry, it's taking more efforts than I thought - hope it's all worth the extra effort. Also, if you let me know which UI you're using, it might help.
Windows 8.1 IE11
Windows 8.1 Chrome Version 55.0.2883.87 m (showing only the default filter condition, as intended)
Windows 8.1 FireFox 50.0 (showing only the default filter condition, as intended)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 01:45 PM
Hi John,
I am using Firefox and Chrome. The first two filter lines produced "onChange script error: TypeError: filter is null function ".
The last one produced a long output - I can share if you want, but I am not sure it is worth your time...
Thanks anyway for putting-in the effort!
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 01:49 PM
If you can share with me, I'll take a quick look.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-13-2017 02:05 PM
If you can share the contents of the alert box (in Chrome, just press Ctrl-C; in FireFox, select the text and copy), that would be more helpful.