Dynamics 365 Business Central: Changing caption/name of existing field (Two ways)

Dynamics 365 Business Central

Hi, Readers. Wish you get all the success this year. Hope that joy and success follow you in every sector of life. Happy New Year 2022!

Today I would like to talk about a simple topic, how to change default caption/name of existing field in Business Central. For example, the client wants to change the “No.”to “Item Number” and “Inventory” to “Stock” on the Item List, is it possible?

Yes, but we can’t do this in standard features, we need small customizations. In this post, I will share two ways, hope this helps.

First let’s take a look at the standard Item List page and Item table.
On the Item list page:

In Item table:

1. Using PageExtension to modify the caption of the field or add a new caption.

Source code:

pageextension 50100 ItemListExt extends "Item List"
{
    layout
    {
        modify("No.")
        {
            Caption = 'Item Number';
        }

        modify(InventoryField)
        {
            Caption = 'Stock';
        }
    }
}

The caption will be changed.

Note: This method affects all languages.
Test Video:

2. Using XLIFF translation file (.xlf file)

In the app.json file of your extension, add the following line:
“features”: [“TranslationFile”],

Then package then extension.

XLIFF file will be generated. Because the current extension does not contain any object, the generated translation file is empty.

Copy a new file and change the value of orginial to “Base Application”.

OK, the preparation work is done, the next step is a bit more complicated. You need to find standard translation files provided by Microsoft. The easiest way is to get this file from the On-Premise installation package.

~\Dynamics.365.BC.33504.W1.DVD\Applications\BaseApp\Source

Base Application.en-US.xlf:

The caption of “No.” in Item table.

The caption of “Inventory” in Item table.

Copy the required part into the translation file you just created, and then modify the target part to the text you need.

Source code:

<?xml version="1.0" encoding="utf-8"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
  <file datatype="xml" source-language="en-US" target-language="en-US" original="Base Application">
    <body>
      <group id="body">
        <trans-unit id="Table 3276313895 - Field 4200184881 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
            <source>No.</source>
            <target state="translated">Item Number</target>
            <note from="Developer" annotates="general" priority="2"></note>
            <note from="Xliff Generator" annotates="general" priority="3">Table Item - Field No. - Property Caption</note>
          </trans-unit>
        <trans-unit id="Table 3276313895 - Field 2105307182 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
            <source>Inventory</source>
            <target state="translated">Stock</target>
            <note from="Developer" annotates="general" priority="2"></note>
            <note from="Xliff Generator" annotates="general" priority="3">Table Item - Field Inventory - Property Caption</note>
        </trans-unit>
      </group>
    </body>
  </file>
</xliff>

The caption will be changed.

END

Hope this will help.

Thanks for reading.

ZHU

コメント

タイトルとURLをコピーしました