web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Custom API Query 2 tables one to many relationship with AL Code

(0) ShareShare
ReportReport
Posted on by 45

Hello

I am creating a Query to use as a custom api.

query 50104 producersQuery
{
    QueryType = API;
    APIPublisher = 'testcompany';
    APIGroup = 'demo';
    APIVersion = 'v2.0';
    EntityName = 'producer';
    EntitySetName = 'producers';

    elements
    {
        dataitem(Customer;Customer)
        {
            DataItemTableFilter = IsProducer = Const(True), IsActive = Const(True);
            column(Id; SystemId{ }

            column(customerNumber;"No."){}

            column(producerName; Name{}

            column(IsActive;IsActive){}

            dataitem(ShipToAdress;"Ship-to Address")
            {
                DataItemLink = "Customer No." = Customer."No.";
                SqlJoinType = InnerJoin;
                column(ShipToId;SystemId){}

                column(Address;Address){}

                column(Address_2;"Address 2"){}

                column(City;City){}

                column(Country_Region_Code;"Country/Region Code"){}

                column(Post_Code;"Post Code")

            }



        }
    }
}

api.businesscentral.dynamics.com/.../$metadata

the result i get is 

{
"@odata.context": "">api.businesscentral.dynamics.com/.../$metadata
"value": [
{
"id": "a9c4c4d4-4b34-eb11-bb70-000d3a245cd7",
"customerNumber": "AB1051",
"producerName": "Coyote Flats",
"isActive": true,
"shipToId": "8c1d14be-be55-eb11-89f8-000d3a84b3f8",
"customerNo": "AB1051",
"address": "Box 54",
"auxiliaryIndex1": "BOX54"
},
{
"id": "a9c4c4d4-4b34-eb11-bb70-000d3a245cd7",
"customerNumber": "AB1051",
"producerName": "Coyote Flats",
"isActive": true,
"shipToId": "abf4b5e0-4b34-eb11-bb70-000d3a245cd7",
"customerNo": "AB1051",
"address": "6455 Macleod Trail SW",
"auxiliaryIndex1": "CALGARY"
}
]
}

Is there anything I need to do to get result as such

{
"@odata.context": "">api.businesscentral.dynamics.com/.../$metadata
"value": [
{
"id": "a9c4c4d4-4b34-eb11-bb70-000d3a245cd7",
"customerNumber": "AB1051",
"producerName": "Coyote Flats",
"isActive": true,
"shippingAdresses": [
{
"shipToId": "8c1d14be-be55-eb11-89f8-000d3a84b3f8",
"customerNo": "AB1051",
"address": "Box 54",
"auxiliaryIndex1": "BOX54"
},
{
"shipToId": "abf4b5e0-4b34-eb11-bb70-000d3a245cd7",
"customerNo": "AB1051",
"address": "6455 Macleod Trail SW",
"auxiliaryIndex1": "CALGARY"
}
]
}
]
}

I have the same question (0)
  • IllerisJS Profile Picture
    40 on at

    I think this is what you are looking for: www.kauffmann.nl/.../

    Why do you want to create a Query API?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

#3
ManoVerse Profile Picture

ManoVerse 53 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans