Column cannot be used for $orderby

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:

  • Is not a real table field (it could be a variable, calculated field, or a renamed alias), or
  • Is not properly bound to the source table (e.g., it’s assigned through AL code rather than 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 : 

  • In Business Central, go to Web Services (Search > Web Services).
  • Locate the web service used in Rapidi (check the Object Type = Page and Object ID / Name).
  • Copy the Object ID or Page Name — you’ll need it next. 

B. Open the page object in AL 

  • Open Visual Studio Code (for AL).
  • Search for the Page using its Object ID or Name.
  • Open the layout section → find the field named 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:

  • Correct (bound to table field):
field(LastDateTimeModified; Rec.SystemModifiedAt)
{
    ApplicationArea = All;
}


  • Incorrect (not bound):
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.