I created a new list page because I need a special filter (days difference between two fields).
I'm not sure how to do that filter, are there any examples? I haven't found any on the internet...
Say I want all records where Due Date is 7 days or more before Start Date in my Assemble Header (900) list.
*This post is locked for comments
Yes I was writing that ;-)
I got it, the filter for 0D needs to be this.
SETFILTER("Start Date",'<>%1', 0D);
Thanks for your help Stefano.
Yes
OnOpenPage() SETFILTER("Start Date",'<>0D'); IF FINDSET THEN REPEAT BEGIN IF "Due Date" >= CALCDATE('-7D', "Start Date") THEN MARK(TRUE) ELSE MARK(FALSE); END UNTIL NEXT=0; //Now show only the marked records. MARKEDONLY(TRUE);
Have you placed this code in OnOpenPage trigger?
When debugging, it looks like it works for the first record it finds, but the second iteration, the Start date is empty.... and the calcdate errors.
In the variable list, it looks like the Start date filter is <> today... instead of <> empty date (0D?)
Maybe I've understood now your requirements, sorry :)
Every record has its own Due Date and Start Date fields, and you want only the record where Due Date >= Start Date + 7 days right?
If so, a simple filter is not enough because the calculation (if due or not) must be done for every record. You can use MARKS.
Something like:
SETFILTER("Start Date",'<>0D'); //Remove the empty start date records
IF FINDSET THEN
REPEAT
BEGIN
IF "Due Date" >= CALCDATE('+7D',"Start Date") THEN
MARK(TRUE)
ELSE
MARK(FALSE);
END
UNTIL NEXT=0;
//Now show only the marked records.
MARKEDONLY(TRUE);
How do I "apply" the filter?
I tried to have both lines at the same time in the OnInit but it still gives an error of comparing dates with 0D.
OnInit() SETFILTER("Start Date",'<>0D'); SETFILTER("Due Date",'>=%1',CALCDATE('+7D',"Start Date"));
First apply the filter for Start Date:
SETFILTER("Start Date",'<>0D');
Then:
SETFILTER("Due Date",'>=%1',CALCDATE('+7D',"Start Date"));
Thank you Stefano, It's the basic NAV table, so it's "Due Date".
Now my problem is that sometimes the start date is empty, so I can't do the difference calculation (says invalid date 0D).
How do I exclude those as well?
What is the name of your date field that you want to filter? Is it not called DueDate?
The suggested filter filters the field called "DueDate" for values >= of Start Date + 7 days.
Correct the name of the fields with your correct field name and it should work.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156