Dynamics 365 Business Central: Why can’t users sort, search, or filter certain fields on the page?

Dynamics 365 Business Central

Hi, Readers.
Today I would like to discuss a question that I get asked sometimes, why can’t users sort, search, or filter certain fields on the page?

In Dynamics 365 Business Central, pages are the main way to display and organize data. Pages are the primary object that a user will interact with and have a different behavior based on the type of page that you choose. A page is defined in code as an object composed of controls, properties, actions, and triggers.
page 31 “Item List”:

There are a few things that you can do that will help you scan, find, and limit records on a list. These include sorting, searching, and filtering.
Sorting: Sorting makes it easy for you to get a quick overview of your data.

To sort a list, you can either:

  • Choose a column heading text to toggle between ascending and descending order
  • Choose the drop-down arrow in the column heading, then choose the Ascending or Descending action.

PS: Dynamics 365 Business Central: How to set and change the default sort order of a page

Searching: At the top of each list page, there’s a Search list. Search action that provides a quick and easy way to reduce the records in a list and display only those records that contain the data that you’re interested in seeing.

Filtering: Filtering provides a more advanced and versatile way to control which records are included in a list.

On lists, you set filters by using the filter pane.

Select a cell on the list, choose the drop-down arrow, and then choose the Filter to This Value action.

More details: Sorting, Searching, and Filtering

This is a very powerful feature, but sometimes people ask why custom added fields cannot be sorted, searched, or filtered. For example, there is a custom field below, ZY Item No.

Choose the drop-down arrow, I can only see one What’s this?, and the column heading text cannot be clicked, so it cannot be sorted.

The values ​​in this column cannot be searched either.

Finally, although this field can be found in the filter pane, it cannot be filtered……

Why? If you look at the code, you’ll find the reason. Yes, the reason is very simple. Because this field is a variable, not a real field in the table.

Although adding a new field as a variable to the page may be convenient for developers, it will cause the field to be unable to be sorted, searched, or filtered. If you don’t explain this to your client in advance, it’s likely to cause problems with utilization.
The solution to this problem is also very simple. Don’t use variables, just use real fields. There is no problem with Flowfield either. A simple example, (This may not be a good example for the timing of the assignment)

Let’s test it again.

Sorting:

Searching:

Filtering:

Great. Let’s discuss a further question. If a page containing variables is published to a Web Service, can the field be filtered or sorted? For example,

Filtering:

{
    “error”: {
        “code”: “BadRequest_NotSupported”,
        “message”: “Field ‘ZYItemNoVar’ is not filterable.  CorrelationId:  dfdf916d-42a0-461d-8550-d9372d906493.”
    }
}

Sorting:

{
    “error”: {
        “code”: “BadRequest”,
        “message”: “The column ‘ZYItemNoVar’ cannot be used for $orderby because it is not bound directly to a table field.  CorrelationId:  73a64532-aea5-41d3-b7c9-fce4caffdb63.”
    }
}

END

Hope this will help.

Thanks for reading.

ZHU

コメント

Copied title and URL