Dynamics 365 Business Central: How to change captions of standard Enum values

Dynamics 365 Business Central

Hi, Readers.
Yesterday I was asked a interesting question, whether there is a way to change the caption of the standard Enum in Business Central SaaS. Although this requirement may not be many, in this post I would like to briefly talk about it.

First of all, an enumeration type, also known as an enum in programming, is a keyword used to declare a type that consists of a set of named constants. The list of named constants is called the enumeration list. Enums can be used as table fields, local and global variables, and parameters.
Letā€™s see two examples.

1. Blocked field in table 18 Customer.

enum 139 ā€œCustomer Blockedā€

2. ā€œAccount Typeā€ field in table 81 ā€œGen. Journal Lineā€

enum 81 ā€œGen. Journal Account Typeā€

How to change these captions of the standard Enum values? For example, the client want to change ā€œG/L Accountā€ to ā€œChart of Accountā€.

As you might know, if it is Page or Table, it is not very difficult. In Page Extension and Table Extension, we have the Modify keyword, which can modify standard field captions.

However, in the Enum Extension, there is no such keyword and we can only add new values.
For example,

PS: Enums can be extended in order to add more values to the enumeration list in which case the Extensible property must be set to true. More details: Enumextension object

Of course you can create a new Enum, add the new field to the table and page, and assign the value to the original Enum field when the new field is validated. If itā€™s just one table and one page, itā€™s not too complicated, but if you need to deal with multiple pages, itā€™s more cumbersome, and you need to worry about some breaking changes in future major updates.

So, at this point we should change our mind. You may remember that we discussed two ways to change caption/name of existing field before, which describes how to use XLIFF translation file (.xlf file) to change the standard caption. More details: Changing caption/name of existing field (Two ways)
This time we can use the same way.

Letā€™s use the method mentioned in the blog above, open the standard translation file (.xlf file), and find the Enum that needs to be translated.

Then copy this part into the translation file of your extension, enter the new caption in the target. (Need to pay attention to whether the target-language and original are correct)

The captions of standard Enum values will be changed after the extension is installed.

PS: This will only affect one language, the example is for English (United States), if you need to display captions different from the standard ones in other language, you need use same method to create new translation file for the language (Change the target-language). More about XLIFF translation files (Working with Translations)

Test XLIFF translation file (.xlf file):

<?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="Enum 4149717694 - EnumValue 1682139193 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
          <source>Bank Account</source>
          <target state="translated">ZY Bank Account</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">Enum Gen. Journal Account Type - EnumValue Bank Account - Property Caption</note>
        </trans-unit>
        <trans-unit id="Enum 4149717694 - EnumValue 1994964448 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
          <source>Customer</source>
          <target state="translated">ZY Customer</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">Enum Gen. Journal Account Type - EnumValue Customer - Property Caption</note>
        </trans-unit>
        <trans-unit id="Enum 4149717694 - EnumValue 1498446062 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
          <source>Employee</source>
          <target state="translated">ZY Employee</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">Enum Gen. Journal Account Type - EnumValue Employee - Property Caption</note>
        </trans-unit>
        <trans-unit id="Enum 4149717694 - EnumValue 372951706 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
          <source>Fixed Asset</source>
          <target state="translated">ZY Fixed Asset</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">Enum Gen. Journal Account Type - EnumValue Fixed Asset - Property Caption</note>
        </trans-unit>
        <trans-unit id="Enum 4149717694 - EnumValue 4274826855 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
          <source>G/L Account</source>
          <target state="translated">Chart Of Account</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">Enum Gen. Journal Account Type - EnumValue G/L Account - Property Caption</note>
        </trans-unit>
        <trans-unit id="Enum 4149717694 - EnumValue 377408248 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
          <source>IC Partner</source>
          <target state="translated">ZY IC Partner</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">Enum Gen. Journal Account Type - EnumValue IC Partner - Property Caption</note>
        </trans-unit>
        <trans-unit id="Enum 4149717694 - EnumValue 1936001480 - Property 2879900210" maxwidth="0" size-unit="char" translate="yes" xml:space="preserve">
          <source>Vendor</source>
          <target state="translated">ZY Vendor</target>
          <note from="Developer" annotates="general" priority="2"></note>
          <note from="Xliff Generator" annotates="general" priority="3">Enum Gen. Journal Account Type - EnumValue Vendor - Property Caption</note>
        </trans-unit>
      </group>
    </body>
  </file>
</xliff>

END

Hope this will help.

Thanks for reading.

ZHU

ć‚³ćƒ”ćƒ³ćƒˆ

Copied title and URL