Defined Related List from multiple tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2016 11:48 PM
Hello,
I have the following setup
On Request Item, I have a field called "Completed by change"
On Incident Table, I have a field called "Caused by Change"
On Problem Table, I have two fields called "Resolved by change" and "Caused by change"
Now I have two create Two related lists called "Items Caused by Change" and "Items Resolved by Change" and show up the above tasks
I am not sure how to created a related list from multiple table, like the "Items Resolved by Change" on change table should show up the Request item and the Problem records that are related to the change under this related list
Any help please:(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2016 07:12 PM
Well Figured out the correct answer. I have tested on my dev instance, therefore the reference field names are different from question, On Incident it is Caused_by, and on problem it is 'rfc' which are referring to the change record
I have used arrays in Relationships
Created a relationship where,
Advanced = true
Applies To -- answer = 'change_request';
Query From -- answer = 'task';
Query With
(function refineQuery(current, parent) {
var mergedArray = new ArrayUtil();
var problemArray = [];
var incidentArray = [];
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('caused_by', parent.sys_id);
incidentGR.query();
while(incidentGR.next()) {
incidentArray.push(incidentGR.getValue('sys_id'));
}
/*
Do the same as above for probelm
*/
var problemGR = new GlideRecord('problem');
problemGR.addQuery('rfc', parent.sys_id);
problemGR.query();
while(problemGR.next()) {
problemArray.push(problemGR.getValue('sys_id'));
}
// Make a union of all arrays
mergedArray = mergedArray.concat(problemArray, incidentArray);
current.addQuery('sys_id', 'IN', mergedArray);
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2016 12:41 AM
Can you close the thread then by marking it Answered?
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2016 05:50 PM
I think I have started this thread as discussion. No option to mark it as Answered