web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

Setfilter fuction on table records

(0) ShareShare
ReportReport
Posted on by 305

Hi

I have an extension of the employee list page on which I have applied a filter for all the records whose birthday is the current day. I wrote my logic including the date variables and the filters in the OnAfterGetRecord trigger of the Employee list page.

EmployeeTable.SetFilter(MonthName, MonthToday1);
EmployeeTable.SetFilter(DayName, DayToday1);
MonthName and DayName being the birth month and day of the records in a new table extension of Employee table. MonthToday1 and DayToday1 are the current month and day of the system.
 
However, when I open the employee list page, it shows an error stating the employee doesn't exist.
What could possibly my mistake? Please help.
 
Thanks in advance!
Categories:
  • Suggested answer
    Community Member Profile Picture
    on at

    Try:

    EmployeeTable.SetFilter(MonthName, '=%1', MonthToday1);

    EmployeeTable.SetFilter(DayName, '=%1', DayToday1);

    That should fix it. Or use setrange:

    EmployeeTable.SetRange(MonthName, MonthToday1);

    EmployeeTable.SetRange(DayName, DayToday1);

    Tero

  • khudeja Profile Picture
    305 on at

    Hi Tero,

    I used both the approaches. Error still persists.

    I've quoted the message below:

    Employee: There is no Employee within the filter.

    Filters: MonthName: 9, DayName: 18

    This appears on the message box.

    Khudeja

  • Community Member Profile Picture
    on at

    Oh, Right, Your code should probably be in the OnOpenPage trigger to begin with. Can you copy paste the whole code here or iclude a picture of how the page looks in designer?

    Tero

  • khudeja Profile Picture
    305 on at

    Setfilter.png

    Hi Tero

    Here is the screenshot of the page.

    Thanks again

  • Suggested answer
    Suresh Kulla Profile Picture
    50,280 Super User 2026 Season 1 on at

    Apply your filters, in the OnOpenPage of the trigger.

  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    Hi

    Why can't you directly filter on the Birth Date field?

    Like:

    Employee.SetRange("Birth Date", Today);

    Regards

    Avinash B

  • khudeja Profile Picture
    305 on at

    Hi Avinash

    This is because it will apply a filter on the year also which I do not want.

    Regards

    Khudeja

  • Community Member Profile Picture
    on at

    Hi,

    Were you able to get this working? If not, go ahead and attach the al object here, I will have a look.

    Tero

  • khudeja Profile Picture
    305 on at

    Hi

    I used SetRange() in the OnOpenPage trigger and it works.

    Thanks for helping out.

    Regards

    Khudeja

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans