FilterPageBuilder.AddField(Text, Any [, Text]) Method

Version: Available or changed with runtime version 1.0.

Adds a table field to the filter control for a table on filter page.

Syntax

[Ok := ]  FilterPageBuilder.AddField(Name: Text, Field: Any [, Filter: Text])

Parameters

FilterPageBuilder
 Type: FilterPageBuilder
An instance of the FilterPageBuilder data type.

Name
 Type: Text

Field
 Type: Any
The name of the table field to add to the filter control for a table.

[Optional] Filter
 Type: Text
A default filter on the field that is specified by the Field parameter.

Return Value

[Optional] Ok
 Type: Boolean
true if the field was added to the field list for the specified filter control; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.

Remarks

If the filter page implementation will call a SetView Method, then the SetView Method must be called before the AddField method call, otherwise the filter that is specified by the Filter parameter will be cleared by SetView Method.

The filter that is specified by the Filter parameter will overwrite any previously defined filters for the field which were set by AddView method or read from the record or recordRef instance that defined the filter control.

Example

The following example initializes a filter page object that includes a filter control for the Date system table. The filter control has the caption of Date record. The example adds two fields of the Date record variable which will be available in the filter control on the filter page: Period End and Period Start. A default filter is set on the Period End field.

var
    varDateItem: Text[30];  
    varDateRecord: Record Date;  
    varFilterPageBuilder: FilterPageBuilder;  

begin     
    varDateItem := 'Date record';  
    varFilterPageBuilder.AddRecord(varDateItem, varDateRecord);  
    varFilterPageBuilder.AddField(varDateItem, varDateRecord."Period End",'12122015D');  
    varFilterPageBuilder.AddField(varDateItem, varDateRecord."Period Start");
    varFilterPageBuilder.RunModal();  
end;

See Also

FilterPageBuilder Data Type
Creating Filter Pages for Tables
Get Started with AL
Developing Extensions