DataSearch UI Implementation - Video Tutorial
Learn how to implement the powerful DataSearch UI for your custom tables in Business Central through this comprehensive video guide!
What You'll Learn
This video tutorial walks you through:
- Understanding the DataSearch framework
- Configuring custom tables for search
- Implementing search templates
- Testing and optimizing search results
- Best practices for user experience
Watch the Full Tutorial
<iframe width="100%" height="480" src="https://www.youtube.com/embed/datasearch-example" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>Introduction to DataSearch in Business Central
The new DataSearch UI introduced in recent waves significantly changes how users interact with data spanning across multiple tables. Instead of navigating to a specific list page and using the search bar, users can now search globally across configured tables directly from their Role Center.
What it means for Developers
As AL developers, this means our custom tables and critical data entities must be properly integrated into the DataSearch framework so users don't miss out on standard platform features.
Code Examples from the Video
Setting Up DataSearch for Custom Tables
Here is a quick example of an install codeunit to insert custom tables:
codeunit 50100 "DataSearch Setup Custom"
{
Subtype = Install;
trigger OnInstallAppPerCompany()
var
DataSearchSetup: Record "Data Search Setup";
begin
if not DataSearchSetup.Get(Database::"My Custom Table") then begin
DataSearchSetup.Init();
DataSearchSetup."Table No." = Database::"My Custom Table";
DataSearchSetup."Search Enabled" = true;
DataSearchSetup."Search Template" = 'CUSTOM_SEARCH';
DataSearchSetup.Insert();
end;
end;
}
Creating Search Templates
Define how your data appears in search results:
codeunit 50101 "Custom Search Template"
{
procedure GetSearchTemplate(TableNo: Integer): Text
var
SearchTemplate: Text;
begin
case TableNo of
Database::"My Custom Table":
SearchTemplate := '{"title": "%1", "subtitle": "%2", "fields": ["%3", "%4"]}';
end;
exit(SearchTemplate);
end;
}
Optimizing Search Performance
Add appropriate indexes to your custom tables:
table 50100 "My Custom Table"
{
fields
{
field(1; "Code"; Code[20])
{
Caption = 'Code';
}
field(2; "Description"; Text[100])
{
Caption = 'Description';
}
field(3; "Search Text"; Text[250])
{
Caption = 'Search Text';
}
}
keys
{
key(PK; "Code")
{
Clustered = true;
}
key(Search; "Search Text")
{
// Optimize for DataSearch queries
}
}
}
Video Chapters
- 00:00 - Introduction to DataSearch
- 02:15 - Prerequisites and Setup
- 05:30 - Configuring Custom Tables
- 08:45 - Creating Search Templates
- 11:20 - Testing Your Implementation
- 14:00 - Performance Optimization
- 16:30 - Common Pitfalls to Avoid
- 18:15 - Advanced Techniques
Real-World Example
In the video, we implement DataSearch for a custom Customer Projects table:
table 50101 "Customer Project"
{
fields
{
field(1; "Project No."; Code[20])
{
Caption = 'Project No.';
}
field(2; "Customer No."; Code[20])
{
Caption = 'Customer No.';
TableRelation = Customer;
}
field(3; "Project Name"; Text[100])
{
Caption = 'Project Name';
}
field(4; "Status"; Enum "Project Status")
{
Caption = 'Status';
}
field(5; "Start Date"; Date)
{
Caption = 'Start Date';
}
}
keys
{
key(PK; "Project No.")
{
Clustered = true;
}
key(SearchKey; "Project Name", "Customer No.")
{
}
}
}
Testing Your Implementation
Follow these steps shown in the video:
- Enable DataSearch in Business Central settings
- Navigate to Role Center and open the search bar
- Enter search terms that match your custom data
- Verify results appear with correct formatting
- Test performance with large datasets
PowerShell Testing Script
# Test API endpoint for DataSearch
$bcUrl = "https://api.businesscentral.dynamics.com/v2.0/tenant/env"
$searchQuery = "projects"
$params = @{
Uri = "$bcUrl/api/microsoft/search/v1.0/search"
Method = "POST"
Headers = @{
"Authorization" = "Bearer $token"
"Content-Type" = "application/json"
}
Body = @{
"requests" = @(
@{
"entityTypes" = @("list")
"query" = @{
"queryString" = $searchQuery
}
}
)
} | ConvertTo-Json -Depth 5
}
Invoke-RestMethod @params
Common Issues & Solutions
Issue 1: Custom Table Not Appearing
Solution: Verify the table is registered in Data Search Setup table
Issue 2: Search Results Display Incorrectly
Solution: Check your search template format and field mappings
Issue 3: Slow Search Performance
Solution: Add appropriate indexes and limit the number of searchable fields
Best Practices
- Limit Searchable Fields - Only include fields users actually need to search
- Use Appropriate Indexes - Add search-optimized indexes to improve performance
- Consistent Templates - Use similar templates across related tables
- Test with Real Data - Always test with production-like data volumes
- Document Requirements - Clearly document which tables are searchable
Additional Resources
Next Steps
After completing this tutorial:
- Implement DataSearch for your custom tables
- Create consistent search templates
- Optimize performance with appropriate indexes
- Test thoroughly with users
- Monitor search performance in production
Download Resources
- Sample code from the video
- DataSearch setup checklist
- Performance testing scripts
- Template examples
All resources are available in the video description!
Found this helpful? Like and subscribe for more Business Central development tutorials. Drop your questions in the comments!