This time I want to discuss how to change a page title caption in Business Central. I was asked this question last week, so I think I should write a blog about this.
You should have noticed some fields that appear to the left of the caption on pages that display the contents of this table.
For example: The customer No. and Name are displayed in the customer card below.
So can we control what to display in the upper left corner of the page? The answer to the question is yes.
First let’s take a look at standard source code of Customer table, we can easily find the DataCaptionFields Property as below. “No.” and Name are been set by default. So on the customer card page the customer No. and Name are displayed.
So, anytime you want to change the caption, just create a TableExtension, and set the fields you want to display.
DataCaptionFields = “No.”, Name, City, “Payment Terms Code”;
Customer Card title caption has been changed. This is a very useful property because it is easy to find the right information on the title and instead of looking over all the fields on the card page.
Although you can also set DataCaptionFields property in a new Page, it cannot be set in PageExtension.
Remark (FM MS Docs):
Card pages display one record at a time. For this object, the value of the underlying table’s DataCaptionFields property is used; the value of this property on the page is ignored. If the DataCaptionFields property is not defined on the table, the primary key is used.
Tabular pages show multiple records at a time. The following data caption rules are applied:
A data caption is only displayed if a filter containing the fields defined in the DataCaptionFields property for the page evaluate to one value. In this case, two situations are possible:
- There is a table relation (as defined by the TableRelation Property) on one or more of the fields. In this case, the DataCaptionFields from the underlying table are used. If this table does not have a value for the DataCaptionFields property, the primary key for that table is used.
- There is no table relation. In this case, the (single) value that results from evaluating the filter is used directly.
Find out more about DataCaptionFields Property from Microsoft Docs.
Hope this will help.
Thanks for your reading.