
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2016 02:53 PM
I have a feeling I am missing something obvious here... The use case is specific to the creation of a Call record, but should apply to the creation of any record.
When creating a new Call, as soon as the Caller field is changed, I want to display a related records table with all open Incidents for the caller.
The flow would be:
- User Clicks New Call
- User enters a valid Caller Name
- User tabs or otherwise leaves the Caller Name field
- A related list containing all open incidents for the caller appears
I've tried using an onChange client script with the following:
GlideList2.get(g_form.getTableName() + '.YOUR_RELATED_LIST_NAME_HERE').setFilterAndRefresh('');
which I found at
Reload a Form or Related list from a Client Script - ServiceNow Guru
but this doesn't seem to be what I need. To be clear, I want the list to show before the new record is submitted.
I tried the above with List V3 turned off using "GlideList2" and with List v3 turned on using "GlideListV3".
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:00 PM
I came up with a workaround. I have a client script that is saving the record on change for the field in question, triggering the related lists to show.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '' || oldValue == newValue)
return;
g_form.save();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:06 PM
Hi John,
The UI Macro client script that I have proposed you can allow you to do something closer than what you are looking for.
You could load that modal window automatically on change if the caller has open incidents:
1. Client callable script include "IncidentRelatedListAjax":
var IncidentRelatedListAjax = Class.create();
IncidentRelatedListAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
hasOpenIncident: function(){
var userId = this.getParameter('sysparm_user_id');
var incident = new GlideRecord('incident');
incident.addActiveQuery();
incident.addQuery('caller_id', userId);
incident.query();
if(incident.next()){
return true;
}
else{
return false;
}
},
type: 'IncidentRelatedListAjax'
});
2. Client onChange script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax('IncidentRelatedListAjax');
ga.addParam('sysparm_name', 'hasOpenIncident');
ga.addParam('sysparm_user_id', newValue);
ga.getXMLAnswer(function(answer){
if(answer == 'true'){
try {
var displayValue = g_form.getDisplayValue('caller');
var title = 'Showing records related to: ' + displayValue;
var query = 'caller_id' + '=' + newValue;
query += '^' + 'active=true';
var gdw = new GlideModal('show_list');
gdw.setTitle(title);
gdw.setSize(750);
gdw.setPreference('table', 'incident_list');
gdw.setPreference('sysparm_query', query);
gdw.setPreference('title', 'A New Title');
gdw.render();
} catch (e) {
jslog('error showing related list');
jslog(e);
}
}
});
}
I would suggest that you still keep the UI Macro has the user could want to reopen the modal after he closes it.
This solution avoid an additional click but also kind of force your user to watch open incidents. Depending on what you want this could be a positive or negative thing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2016 03:00 PM
I came up with a workaround. I have a client script that is saving the record on change for the field in question, triggering the related lists to show.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '' || oldValue == newValue)
return;
g_form.save();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2018 12:55 PM
Hello Tomko,
I'm trying to achieve same functionality but couldn't. Anything else to be created other than Client script you mentioned above.
Any help is appreciated. Thank you!