- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 05:39 AM
We have a parent table (x_datrp_maintenanc_parent_datalink_contract) and a child table (u_datalink_contract_item). The following relationship script allows me to display all related child records from the parent form by pulling all child contracts that have the same contract number, company, and coverage type manufacturer.
current.addQuery('u_dynamics_ax_contract_number', parent.getDisplayValue('u_insight_contract_number')).addCondition('company', parent.getValue('u_company')).addCondition('u_coverage_type_manufacturer', parent.getValue('u_manufacturer'));
Now I want to be able to display all attachments from the child table records, from the parent form. I know the table is sys_attachment.
I don't think I can create the same kind of "Query With" relationship since there are three tables involved. Do I need to create a custom query using an advanced relationship? Would I put the code in "query from"? Anyone have a code example of this?
Thanks
David Wilhelm
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 05:48 AM
David,
If I understand the question. You want to display all attachments related to parent table child records as a related list on the parent form.
Below is what I did for all Project attachments at the project level. Line 5 through 10 will need to be reworked on what you are doing but atleast you might be bale to use the setup I did.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 05:44 AM
Hi David,
Where do you want to display the attachments for the child records and why? A screenshot or mockup would be useful - you know what they say about a picture being worth 1000 words...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 05:48 AM
David,
If I understand the question. You want to display all attachments related to parent table child records as a related list on the parent form.
Below is what I did for all Project attachments at the project level. Line 5 through 10 will need to be reworked on what you are doing but atleast you might be bale to use the setup I did.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 07:36 AM
Thanks for the reply Patrick. You got me to where I needed to go.
Here is what I came up for my scenario which works.
var sysIDs = "";
var gr = new GlideRecord("u_datalink_contract_item");
gr.addQuery('company', parent.getValue('u_company'));
gr.addQuery("u_coverage_type_manufacturer", parent.getValue('u_manufacturer'));
gr.addQuery('u_dynamics_ax_contract_number', parent.getDisplayValue('u_insight_contract_number'));
gr.query();
while(gr.next()){
sysIDs += ", " + gr.sys_id;
}
current.addQuery("table_name", "IN", "x_datrp_maintenanc_parent_datalink_contract, u_datalink_contract_item");
current.addQuery("table_sys_id", "IN", sysIDs);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 07:39 AM
Awesome. I would suggest putting the sys_ids in an array vs building out the string.