GETRANGEMAX Function (Record)

Gets the maximum value in a range for a field.

Value := Record.GETRANGEMAX(Field)

Parameters

  • Record
    Type: Record The record that contains the field.
  • Field
    Type: Field The field for which you want to find the maximum value. The current filter on Field must be a single range filter; otherwise, a run-time error occurs.

Property Value/Return Value

Type: Depends on Field

Contains the maximum value of the range set for Field. The type of the return value must match the type of Field.

Example

In this example, you have a filter that defines a single range.

This example requires that you create the following variables and text constant in the C/AL Globals window.

Variable name DataType Subtype Length

CustomerRec

Record

Customer

Not applicable

Val

Code

Not applicable

10

Text constant ENU value

Text000

The maximum value is: %1.

CustomerRec.SETFILTER("No.",'100..200');
Val := CustomerRec.GETRANGEMAX("No.");
MESSAGE(Text000, Val);

The following message is displayed:

The maximum value is: 200.

In this example, you have a filter that is a single value.

This example requires that you create the following variables and text constant in the C/AL Globals window.

Variable name DataType Subtype Length

CustomerRec

Record

Customer

Not applicable

Val

Code

Not applicable

10

Text constant ENU value

Text000

The maximum value is: %1.

CustomerRec.SETFILTER("No.",'100');
Val := CustomerRec.GETRANGEMAX("No.");
MESSAGE(Text000, Val);

The following message is displayed:

The maximum value is: 100.

In this example, you have a filter that is not a single range.

This example requires that you create the following variables and text constant in the C/AL Globals window.

Variable name DataType Subtype Length

CustomerRec

Record

Customer

Not applicable

Val

Code

Not applicable

10

Text constant ENU value

Text000

The maximum value is: %1.

CustomerRec.SETFILTER("No.",'200|300');
Val := CustomerRec.GETRANGEMAX("No.");
MESSAGE(Text000, Val);

This example causes a run-time error to occur.

See Also

Reference

GETRANGEMIN Function (Record)
Record Data Type