Dear Business Central experts,
I want to create an API query object that links one central table (Sales Header) to two related tables:
- Contact, for showing ship-to contact name, email, phone
- Sales Line, for showing a sum of amounts (Excl. VAT)
When I try it, the following error message appears: "You cannot combine two DataItems at the same level because unions are not supported".
The code for the query object is like below:
====================================
query 70101 "Shipping Postal Address"
{
QueryType = API;
APIPublisher = 'Entocare';
APIGroup = 'E';
APIVersion = 'v1.0';
EntityName = 'shippingPostalAddress';
EntitySetName = 'shippingPostalAddresses';
elements
{
dataitem(shippingPostalAddress; "Sales Header")
{
column(Number; "No.")
{
}
//shipping Address
//....7 columnns omitted for brevity....
//ship-to Contact plus details
column(shipToContact; "Ship-to Contact")
{
}
dataitem(Contact; Contact)
{
DataItemLink = "No." = shippingPostalAddress."Ship-to Contact";
//...3 columns omitted for brevity...
}
//summary of sales lines
dataitem(SalesLines; "Sales Line")
{
DataItemLink = "Document No." = shippingPostalAddress."No.";
column(amountExclVAT; Amount)
{
Method = Sum;
}
}
}
}
}
=================================================
The two dataitems (Contact and SalesLine) are indeed on the same level. They both show a red error mark with the message quoted above.
How to combine these tables in a single query?
In SQL this is easy and there is no union involved. It is just one central table joined to two related tables.
Thanks for your help!
With best regards,
Wolter Kaper