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...
Suggested Answer

API not applying the Location Filter on page part

(2) ShareShare
ReportReport
Posted on by 8
 
Hi!
 
I have a custom API using SourceTable=Item and a page part to the Item Ledger and I'm trying to limit the number of records on the Item Ledger API response by using both a Location Filter and a top
 
https://api.businesscentral.dynamics.com/v2.0/.../items(7250bd46-69b9-ef11-9101-18a90553bf46)?$filter=locationFilter eq 'MAIN'&$expand=itemledgerentries($top=100)
 
However, the LocationFilter does not apply on the page part, only on FlowFields on Item Table. The filtered response from the page part is only using the ItemNo and not the LocationFilter. Why is that?
 
 
page 79126 "FloWMS Items API"
{
...
    EntityName = 'item';
    EntitySetName = 'items';
    PageType = API;
    SourceTable = Item;
...
            repeater(General)
            {
                field(id; Rec.SystemId)
                { }
                field(no; Rec."No.")
                { }
                field(description; Rec.Description)
                { }
                field(qtyOnSalesOrder; Rec."Qty. on Sales Order")
                { }
                field(locationFilter; Rec."Location Filter")
                { }
                part(itemledgerentries; "Item Ledger Entries API")
                {
                    SubPageLink =
                        "Item No." = field("No."),
                        "Location Code" = field("Location Filter");
                }
            }
 
 
Another solution might be to use a filter in the expand part of the URL. The expand works fine with just one parameter inside the bracket but not two. What am I missing?
 
https://api.businesscentral.dynamics.com/v2.0/.../items(7250bd46-69b9-ef11-9101-18a90553bf46)?$filter=locationFilter eq 'MAIN'&$expand=itemledgerentries($filter=locationCode eq 'MAIN'&$top=100)
 
But this gives me an error:
{
    "error": {
        "code": "BadRequest",
        "message": "Found an unbalanced bracket expression.  CorrelationId:  0f3dec82-c1e9-4d2e-9a56-e39ae0f50d33."
    }
}
 
What is the best approach to limit the amount of records from the page part Item Ledger?
 
Best regard
Jan
 
I have the same question (0)
  • Gerardo Rentería García Profile Picture
    25,390 Most Valuable Professional on at

    Hi, good day
    I hope this can help you, and give you some hints.

    Using OData with Queries That are Set with a Top Number of Rows - Business Central | Microsoft Learn

    Best Regards
    Gerardo

  • Jan Höglund, Illumera Profile Picture
    8 on at
    Hello Gerardo!
     
    Thank you for the response. 
     
    Yes, you are right that there are several ways to limit the amount of data and number of records in a request. 
     
    Using a HTML-header key e.g. odata.maxpagesize=100 only applies to the main request and API. In my case the call to the Item API. The page part is just attached and not limited thus making the header-key useless in my case.
     
    My challenge above is still an unsolved mystery. 😊
     
    Best regards
    Jan
  • Suggested answer
    Jan Höglund, Illumera Profile Picture
    8 on at
    Ok, so I found one solution that makes this a little bit easier:

    https://api.businesscentral.dynamics.com/v2.0/.../items(7250bd46-69b9-ef11-9101-18a90553bf46)?$filter=locationFilter eq 'MAIN' &$expand=itemledgerentries($filter=locationCode 'MAIN' $top=30)
     
    To have several parameters sent to the expanded page part they need to be separated by a semicolon.
     
    I will set this as the solution and hope it will help someone else. I'm sure that the solution is somewhere in the docs but I couldn't find it and I solved this by accident. 
     
    It's still a mystery why a FlowFilter is not propagated from the main request down to the page part in an API page. 
     
    Best regards
    Jan
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,971 Super User 2025 Season 2 on at

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 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans