Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / filter a form with dat...
Finance forum
Suggested answer

filter a form with date filter using combo box in X++

Posted on by 100

Hi Experts,
I want to open a form with Date filter  (today+1 ) using combo box .
This Datefilter (combo box) will  filter my Date field of custom form having only one DataSource.

I have created a combo box in form .
how to write logic for this condition.5824.Capture.PNG 

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,540 Moderator on at
    RE: filter a form with date filter using combo box in X++

    It would be because you added date range of minimum value to Today + 1. As per your requirement, it was just Today + 1 on initialization. Please check the code I shared before and modify your date range value.

  • ergun sahin Profile Picture
    ergun sahin 8,812 Moderator on at
    RE: filter a form with date filter using combo box in X++

    I thought it would be hard to detect since you didn't set first value to the control, but I noticed something different.

    Do you only want the records for tomorrow or the records until tomorrow? (You filtered single day in Modified, but you used range in init)

  • ergun sahin Profile Picture
    ergun sahin 8,812 Moderator on at
    RE: filter a form with date filter using combo box in X++

    Set control value at init

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: filter a form with date filter using combo box in X++

    Just last thing.

    filter of today+1 is not working, while opening the form.

  • ergun sahin Profile Picture
    ergun sahin 8,812 Moderator on at
    RE: filter a form with date filter using combo box in X++

    At modified use this.dateValue( not DateControl)

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,540 Moderator on at
    RE: filter a form with date filter using combo box in X++

    Issue still seems to be with your date control, you can create new form control of type date, set EDT as TransDate. Override modified and use the code there.

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: filter a form with date filter using combo box in X++

    Thanks Mohit & Martin.

    Now the code is working fine .

    Thankyou so much ..

  • Martin Dráb Profile Picture
    Martin Dráb 228,041 Super User 2024 Season 2 on at
    RE: filter a form with date filter using combo box in X++

    I would start by changing DateControl.dateValue() to this.dateValue().

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: filter a form with date filter using combo box in X++

    Hi Mohit,

    Moved my code to Data source init. 

    Now getting error in on modified of  Datecontrol

    4846.Capture4.PNG

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,540 Moderator on at
    RE: filter a form with date filter using combo box in X++

    It seems like you have placed the code in form init instead of Form Datasource init. If yes, then please move it to form Datasource init method.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

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

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,246 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,041 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans