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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
#ManoVerse Profile Picture

#ManoVerse 93

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 62 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans