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

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 78

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(CodeCode)
            {

            }
            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!

I have the same question (0)
  • Renato Fajdiga Profile Picture
    1,853 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
    on at

    Thank you so much for sharing final answer.

  • Craig Yu Profile Picture
    78 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
    78 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

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans