Skip to main content

Notifications

Announcements

No record found.

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"
}
]
}
]
}

  • IllerisJS Profile Picture
    IllerisJS 40 on at
    RE: Custom API Query 2 tables one to many relationship with AL Code

    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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans