Export (0) Print
Expand All

SETRANGE Function (Record)

Microsoft Dynamics Nav 2009

Sets a simple filter, such as a single range or a single value, on a field.


Record.SETRANGE(Field [,FromValue] [,ToValue])

Parameters

Record

Type: Record

The record that contains the field that you want to filter.

Field

Type: Field

The field that you want to filter.

FromValue

Type: Any

The lower limit of the range. The data type of this parameter must match the data type of Field.

ToValue

Type: Any

The upper limit of the range. If you omit this parameter, the value that you specified for FromValue is used. The data type of this parameter must match the data type of Field.

SETRANGE is a quick way to set a simple filter on a field.

SETRANGE removes any filters that were set previously and replaces them with the FromValue and ToValue parameters that you specify.

If you use SETRANGE without setting the FromValue and ToValue parameters, the function removes any filters that are already set.

If you set only the FromValue, the ToValue is set to the same value as the FromValue.

This example shows how to use the SETRANGE function to specify that you want to see only customers 100 through 200. This example requires that you create the following variable in the C/AL Globals window.

Variable name DataType Subtype

CustomerRec

Record

Customer

CustomerRec.SETRANGE("No.", '100', '200');
// The above statement is a quick way to set the same filter as:
CustomerRec.SETFILTER("No.", '>=100&<=200'); 

This example shows how to find the first record that has a blank for the requested delivery date. It requires that you create the following variable.

Name Data type Subtype

SalesLineRec

Record

Sales Line

SalesLineRec.SETRANGE("Requested Delivery Date",0D);
IF SalesLineRec.FIND('-') THEN
  MESSAGE('Sales Order %1 has no requested delivery date.', SalesLineRec."Document No.");

Community Additions

ADD
Show:
© 2014 Microsoft