This error occurred while reading data from Microsoft Dynamics 365 Business Central (BC) via an ODATA connection. The integration attempted to execute an OData query including an $orderby=LastDateTimeModified clause.
400 Bad Request: The column 'LastDateTimeModified' cannot be used for $orderby because it is not bound directly to a table field.
In Business Central, each field on the Odata page must be bound directly to a table field to be eligible for sorting or filtering via OData.
The error indicates that the field LastDateTimeModified:
SourceExpr = Rec.FieldName).Due to this, Business Central cannot use it in the $orderby clause — OData only supports sorting on real table-bound fields that exist in a table key definition.
How to Troubleshoot & Fix:
A. Identify the OData Page used by the integration :
Search > Web Services).B. Open the page object in AL
LastDateTimeModified (or the exact field that is used for $orderby).C. Check if the field is bound to a table field and the necessary changes:
field(LastDateTimeModified; Rec.SystemModifiedAt)
{
ApplicationArea = All;
}field(LastDateTimeModified; MyVar)
{
ApplicationArea = All;
}
Or
field(LastDateTimeModified; SomeCalculatedValue)
{
ApplicationArea = All;
}
If it’s not bound to a real table field (Rec.<FieldName>), OData cannot use it for $orderby.
Comment Editor X