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 :
Small and medium business | Business Central, N...
Active Discussion

How to make a Query in extension expose all items' inventory quantity under locations by sending only one request

(0) ShareShare
ReportReport
Posted on by 88

Hi all,

 

We are writing a API-Type-Query in our extension code to expose all items' inventory quantity under each locations seperately by one request only,

after we published the extension to test this query, we got a error like this:

---

{
    "error": {
        "code": "Unknown",
        "message": "The following SQL error was unexpected:\r\nInvalid column name 'Location Filter'.\r\nStatement(s) could not be prepared.\r\n  CorrelationId:  72cdcaa7-ff3e-4918-b6f7-31997dc52325."
    }
}

---

 

Here is our code:

---

query 70203509 TRCItemInventoryLocationAPI
{
    QueryType = API;
    APIPublisher = 'TrueCommerce';
    APIGroup = 'TRC';
    APIVersion = 'v1.0';
    EntityName = 'itemInventoryQuantity';
    EntitySetName = 'itemInventoryQuantities';

    elements
    {
        dataitem(Location; Location)
        {
            column(Code; Code)
            {

            }
            dataitem(Item; Item)
            {
                DataItemLink = "Location Filter" = Location.Code;

                column(itemNo; "No.")
                {

                }
                column(Inventory; Inventory)
                {

                }
            }
        }
    }

    var
        myInt: Integer;

    trigger OnBeforeOpen()
    begin

    end;
}

---

 

We are wondering if there could be a way to make this query work,

or if there is any other solution to get all items' inventory quantity under each locations seperately by sending only one request.

Thanks!

  • Renato Fajdiga Profile Picture
    1,855 on at

    Hi,

    try using Item Ledger Entry data item with a filter on Open = True. There you have all transactions for the items together with location code.

  • Ethan-Sorenson Profile Picture
    225 on at

    This worked for me.

    query 63001 TRCItemInventoryLocationAPI

    {

       QueryType = API;

       APIPublisher = 'TrueCommerce';

       APIGroup = 'TRC';

       APIVersion = 'v1.0';

       EntityName = 'itemInventoryQuantity';

       EntitySetName = 'itemInventoryQuantities';

       OrderBy = ascending(LocationCode), ascending(ItemNo);

       elements

       {

           dataitem(ItemLedger; "Item Ledger Entry")

           {

               //DataItemTableFilter = "Location Code" = filter(<> '');

               column(ItemNo; "Item No.")

               {

               }

               column(LocationCode; "Location Code")

               {

               }

               column(Quantity; "Quantity")

               {

                   Method = Sum;

               }

           }

       }

       var

           myInt: Integer;

       trigger OnBeforeOpen()

       begin

       end;

    }

  • Marco Mels Profile Picture
    Microsoft Employee on at

    Thank you so much for sharing final answer.

  • Craig Yu Profile Picture
    88 on at

    Thank you Renato,

    Now we can get the sum quantity which is grouped by item code and location code from table Item Ledger Entry.

    Thanks again!

  • Craig Yu Profile Picture
    88 on at

    Thanks Ethan,

    Your code did help a lot for us, thanks again!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 554 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 344 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 189 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans