Creating Zero Fill Character Fields

You can customize the system so that a field is automatically filled to the left with zeros after the user enters a value. For example, if a field has a maximum size of 20 characters and a user types the value 12345 in the field, the system would automatically add fifteen zeros preceding the value.

To create zero fill character fields, you must add the ZeroFill argument to the MaxLength validation rule type for the desired field in the custom business metadata. You can access the business metadata through the Entity Overview, on the Business Metadata Summary component.

Copy existing code

On the Base Metadata tab, if the field has a MaxLength rule as part of the base validation, copy the text in the base metadata as shown below:

<EntityAttribute id="TransactionNumber" type="char" key="true" label="Transaction Number" shortLabel="Transaction Num" defaultSortIndex="1" unique="true">

          <ValidationRules>

            <Rule type="IsRequired" canOverride="false" />

            <Rule type="MaxLength" canOverride="false">

              <Arguments>

                <Argument name="MaxAllowed">4</Argument>

              </Arguments>

            </Rule>

          </ValidationRules>

        </EntityAttribute>

Paste and customize code

  1. Click the Custom Metadata tab, and paste the text under the appropriate field in the custom metadata.

  2. Then, as shown below, insert:

    The IsNumber rule, to ensure that the field will sort correctly.

    The Precision argument, to ensure that the system knows the correct number of characters to fill.

    The ZeroFill argument, to fill the extra characters.

  3. Click the Save button.

 

<EntityAttribute id="TransactionNumber" type="char" key="true" label="Transaction Number" shortLabel="Transaction Num" defaultSortIndex="1" unique="true">

          <ValidationRules>

            <Rule type="IsRequired" canOverride="false" />

            <Rule type="IsNumber" canOverride="false">

              <Arguments>

                <Argument name="Precision">10</Argument>

                <Argument name="MinAllowed">1</Argument>

              </Arguments>

            </Rule>

            <Rule type="MaxLength" canOverride="false">

              <Arguments>

                <Argument name="MaxAllowed">4</Argument>

                <Argument name="ZeroFill">true</Argument>

              </Arguments>

            </Rule>

          </ValidationRules>

        </EntityAttribute>

Related topics:

Customizing Entities

Editing the Business Metadata

 

Blue bar indicating the end of the topic