<turbo-stream action="update" target="wiki_card"><template>

<h1>Column cannot be used for $orderby</h1>
<div class="trix-content"><p>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 <code>$orderby=LastDateTimeModified</code> clause.<br><br></p><p><code>400 Bad Request: The column 'LastDateTimeModified' cannot be used for $orderby because it is not bound directly to a table field.</code></p><p><br>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.</p><p>The error indicates that the field <code>LastDateTimeModified</code>:</p><ul><li>Is not a real table field (it could be a variable, calculated field, or a renamed alias), or</li><li>Is not properly bound to the source table (e.g., it’s assigned through AL code rather than <code>SourceExpr = Rec.FieldName</code>).</li></ul><p>Due to this, Business Central cannot use it in the <code>$orderby</code> clause — OData only supports sorting on <em>real table-bound fields</em> that exist in a table key definition.<br><br><strong>How to Troubleshoot &amp; Fix:<br><br></strong><strong><u>A. Identify the OData Page used by the integration :&nbsp;</u></strong></p><ul><li>In Business Central, go to <strong>Web Services</strong> (<code>Search &gt; Web Services</code>).</li><li>Locate the web service used in Rapidi (check the <strong>Object Type = Page</strong> and <strong>Object ID / Name</strong>).</li><li>Copy the <strong>Object ID</strong> or <strong>Page Name</strong> — you’ll need it next.&nbsp;</li></ul><p><strong><u>B. Open the page object in AL&nbsp;</u></strong></p><ul><li>Open Visual Studio Code (for AL).</li><li>Search for the Page using its Object ID or Name.</li><li>Open the <strong>layout</strong> section → find the field named <code>LastDateTimeModified</code> (or the exact field that is used for <code>$orderby</code>).</li></ul><p><strong><u>C. Check if the field is bound to a table field and the necessary changes:</u></strong></p><ul><li><strong>Correct (bound to table field):</strong></li></ul><pre><code>field(LastDateTimeModified; Rec.SystemModifiedAt)<br>{<br>&nbsp; &nbsp; ApplicationArea = All;<br>}</code></pre><p><br></p><ul><li><strong>Incorrect (not bound):</strong></li></ul><pre><code>field(LastDateTimeModified; MyVar)<br>{<br>&nbsp; &nbsp; ApplicationArea = All;<br>}</code></pre><p>&nbsp;&nbsp;<br>Or</p><pre><code>field(LastDateTimeModified; SomeCalculatedValue)<br>{<br>&nbsp; &nbsp; ApplicationArea = All;<br>}</code></pre><p><br>If it’s not bound to a real table field (<code>Rec.&lt;FieldName&gt;</code>), OData <strong>cannot</strong> use it for <code>$orderby</code>.</p></div>
</template></turbo-stream>

