
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2017 03:21 AM
Hello Everyone,
I have a requirement when ever i select any record in Parent list filed respective child list should fall in child list field.
I achieve this however adding more than one parent to Parent List field unable to populate old + new records, i can only view old records. Below is the the thread with which i achieve to populate from Parent and child records.
How to populate/display Child records with reference to Parent table
Thanks in advance.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2017 09:19 AM
I'm not entirely clear on the latest issue.
You populated the child records from the parents listed. That sounds like it makes sense and is working as per your earlier requirement.
Correct me if I'm wrong on this part:
- You unlock the child record
- You remove some of the entries
- You lock the child record
- You unlock it again, and all original entries are there?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2017 05:54 AM
Hi Abdul,
I'm not quite understanding the requirement. Please forgive me. Can you include some screenshots of what you are trying to accomplish?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2017 06:42 AM
I have 2 List type fields named as Parent & Child both are referring to Service offering table as shown below:
whenever i go into Parent and select any Parent record say like 'abdul' it should autopopulate all the child records of abdul in to Child Type field. which is happening as shown below:
But later if i select additional parent record unable to populate old + new records, i can only view old records.
Example: if i select 'azeez' from the parent record as shown in 2nd image it must populate azeez child records as well including previous child records.
I hope you got it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2017 06:56 AM
It sounds like a fairly simply onChange client script on the parent field to do a GlideAjax call and find the sys_ids of all child records of the parents specified and return a comma separated list of sys_ids of all child records related to the parent field. Something like this... note, this is untested code and uses made up field/table names.
/// CLIENT SCRIPT ///
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === '') {
return;
}
var ga = new GlideAjax('MyScriptInclude');
ga.addParam('sysparm_name', 'getChildren');
ga.addParam('sysparm_parent', newValue);
ga.getXML(processAnswer);
}
function processAnswer(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('u_child', answer);
}
/// SCRIPT INCLUDE ////
var MyScriptInclude = Class.create();
MyScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getChildren : function() {
var pStr = this.getParameter('sysparm_parent');
var pList = pStr.split(',');
var cList = [];
for (var i = 0 ; i < pList.length; i++) {
var cGr = new GlideRecord(YOUR_CHILD_TABLE);
cGr.addQuery('parent', pList[i]); // use your real parent field name from the child table
cGr.query();
while (cGr.next()) {
cList.push(cGr.getValue('sys_id'));
}
}
return cList.join(',');
},
type: 'MyScriptInclude'
});
Docs: Client Scripts
Docs: GlideForm
Docs: GlideAjax
Client Script Best Practices - ServiceNow Wiki

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2017 09:08 AM
ctomasi Chuck ,
Thats working AWESOME.
But there is small issue can you please help me out on it ?
Whenever i selected multiple parent records example: IT Service Management, azeez then all the child records have been populating in Child field. as shown below:
but when i select only highlighted records from the child field and save/updated, i want only selected records but when i re-opened i can see all the records again.
Can you please help me out to achieve only view selected records ?