AL Page: show integer or decimal as mandatory

 

A quick tip, as it’s been a while since my last post..

The ShowMandatory property for fields on a page object is helpful for drawing the user’s attention to required fields on a page.

If a field is not populated on a page and the ShowMandatory property for that field is set to true, then a red asterisk (*) will appear:

Mandatory Decimal

The problem is, for number based fields which default to 0, this field is actually populated so the asterisk will not show up.

Luckily there is an easy solution; to show integer or decimal fields as mandatory we can also set the field’s BlankZero field to true:

pageextension 50000 "Item Card DK" extends "Item Card"
{
    layout
    {
        modify("Net Weight")
        {
            BlankZero = true;
            ShowMandatory = true;
        }
}
If you have more complex (or fringe) requirements, such as numbers must be positive, there is also the BlankNumbers page field property. BlankNumbers can be set to the following values:
Value Description
DontBlank (default) Not clear any numbers
BlankNeg Clear negative numbers
BlankNegAndZero Clear negative numbers and zero
BlankZero Clear numbers equal to zero
BlankZeroAndPos Clear positive numbers and zero
BlankPos Clear positive numbers

Note: BlankNumbers is not available when modifying fields from a pageextension object, you can only use this property on a  field declaration.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.