With the release of Business Central 2025 Wave 1, Microsoft continues to empower developers with more control and insights into the performance and behavior of their extensions. Among the new additions is the method FieldRef.IsOptimizedForTextSearch()
, designed to help developers make more performance-conscious decisions when implementing search functionalities.
FieldRef.IsOptimizedForTextSearch()
?FieldRef.IsOptimizedForTextSearch()
is a method that returns a Boolean value indicating whether a particular field in a table is optimized for text search.
It is a method on the FieldRef
data type, which is used in AL code to dynamically refer to fields of records, especially in scenarios involving field iteration, metadata handling, or dynamic filters.
Syntax:
Boolean := FieldRef.IsOptimizedForTextSearch();
While IsOptimizedForTextSearch()
only checks if a field is optimized, setting it up is done via the table metadata or through the table schema in AL.
To mark a field for text search:
field(10; Description; Text[100])
OptimizeForTextSearch = true;
{
Caption = 'Description';
DataClassification = ToBeClassified;
}
Setting OptimizeForTextSearch = true;
enables text search optimization (depending on SQL backend settings as well for on-premise).
Lets see how we can utlize above method to check optimize search
var
MyRecordRef: RecordRef;
MyFieldRef: FieldRef;
IsOptimized: Boolean;
begin
MyRecordRef.Open(Database::Customer);
if MyRecordRef.FindSet() then begin
MyFieldRef := MyRecordRef.Field(Name); // Let's check the "Name" field
IsOptimized := MyFieldRef.IsOptimizedForTextSearch();
if IsOptimized then
Message('The "%1" field in the Customer table is optimized for text search.', MyFieldRef.Name())
else
Message('The "%1" field in the Customer table is NOT optimized for text search.', MyFieldRef.Name());
end;
MyRecordRef.Close();
end;
To be optimized for full-text search, a field typically needs:
The FieldRef.IsOptimizedForTextSearch()
method is a small but powerful tool in the AL developer’s toolkit. Whether you’re designing smarter search UIs or optimizing performance in large datasets, this method gives you the metadata visibility to make informed choices.
By leveraging this feature, you can:
Stay tuned for more..
Original Post https://ammolhsaallvi.blog/2025/04/23/fieldref-isoptimizedfortextsearch-method-in-business-central-2025-wave-1/