Im trying to finalize a report which shows employees who've not contributed their monthly contributions.
The employee table contains all employees and the contributions table contain all employees who've contributed at least once.
I want to be able to list all employees who've not contributed for a specific range. The contributions table contains from date and to date fields. Now I want to use the virtual date table with period start and period end to list all employees who are not in the contributions table for the specified date range by comparing form date,to date and period start, period end respectively.
I've tried the method below and similar filtering:
Cont.SETRANGE("Employee No.",Employee."No.");
Cont.SETFILTER(Cont."From Date", '>=%1', DtVir."Period Start");
Cont.SETFILTER(Cont."To Date",'<=%1', DtVir."Period End");
IF Cont.FIND('-')
THEN
CurrReport.SKIP;
to no avail.
In sql programming this what I want
Select * from employee where employee.No. != [Subquery select Contributions.'Employee No.' where Date.'Period Start' >=Contributions.'From date' and Date.'Period End' <= Contributions.'To Date']
Any ideas please!
Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?
0
Comments
And i pressume this is all done on employee dataitem onaftegerrecord?
Once again the filters I apply aren't working! ](*,)
Here when I only filter by employee no all employees in the contributions will be skip...An example would be if an employee paid for january and february then if the date range is january 1st to 31st the employee should appear once i.e for february.
The filters here I think is working by or while it should work with and. A record should only be skipped if all conditions are true...
Better ideas please!
[/i]
2. Try use
Cont.SETRANGE("From Date", DtVir."Period Start", DtVir."Period End");
Cont.SETRANGE("To Date", DtVir."Period Start", DtVir."Period End");
2) What is it "DtVir"? You didn't wrote how the variable is filled and meaning of this variable...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
And below are the filters am trying to use, I updated the code:
Cont.SETRANGE("From Date", Date."Period Start");
Cont.SETRANGE("To Date", Date."Period End");
Cont.SETRANGE("Employee No.",Employee."No.");
IF Cont.FIND('-')
THEN
CurrReport.SKIP;
The user has to enter Period Start and Period End when previewing the report.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I've also used the following to pick dates between to no avail:
Cont.SETRANGE("Employee No.",Employee."No.");
Cont.SETFILTER("From Date",'>=%1', Date."Period Start");
Cont.SETFILTER("To Date",'<=%1',Date."Period End");
IF Cont.FIND('-')
THEN
CurrReport.SKIP;
May be am missing something...
Ideas welcomed please!
2) Do not forget to use .RESET before setting first filter to be sure that there is no other filters set in another part of code
3) In which trigger you have this code? In which DataItem?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
2) There's no other code in the report. Only two dataitems are in the report and they are employee and date as mentioned in earlier post.
3) The code is in the Employee dataitem and in the trigger OnAfterGetRecord.
Employee xxx is on the report in period XXX..YYY but in table Cont is record Employee No.=xxx, start date=XXX, end date=YYY...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
ZS0006 Some Name 19/03/2007 20/03/2007 1,500 20/03/2007 Sample RC004 No
NA2001 Another name 19/03/2007 20/03/2007 1,500 20/03/2007 Sample2 RC004 No
AM0013 Similar One 19/03/2007 20/03/2007 1,500 20/03/2007 Sample3 RC004 No
DC0084 Example 19/03/2007 20/03/2007 1,500 20/03/2007 Sample4 RC004 No
ZS0006 Some Name 21/03/2007 21/03/2007 5,200 21/03/2007 Another RC0008 No
The above list is taken from the contributions table and you can clearly see the From Date and To Date to match Period Start and Period End from the date table respectively. And now when I enter Period Start=19/03/07 and Period End=20/03/07 four of the above records are shown which should not happen as they are within the filter.
There is no such a record in Date table. May be that this is your problem... take these dates as two variables on request form and it will be much better...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Also I was thinking by the user choosing period start and period end dates before previewing the report the filter would work...
Any way how do I implement the request form?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Can you please specifiy how to implement these functions on the OnPreReport trigger.
Also I've added the request form and the date ranges are working now...Except that it filters the employee out completely even if he/she exists in another date different from the one on the request form.
Below is my updated filter:
Cont.SETFILTER("From Date",'>=%1',DateFrom);
Cont.SETFILTER("To Date",'<=%1',DateTo);
Cont.SETFILTER("Employee No.",Employee."No.");
IF Cont.FIND('-')
THEN
CurrReport.SKIP;
where Text000 is text constant with text like "You need to enter both date" and Text001 is "Starting date must be before End Date".
2) I recommend to use instead SETFILTER when you are filtering for one value.
3) And again, have you example of such an employee with the data which are there?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Everything except that now is the problem. I implemented setrange but it is still skipping the employee outside the date range specified on the request form.
I also try the code below but still it didn't work on the OnAfterGetRecord as well on OnPreReport:
IF (Cont."From Date" >= DateFrom) AND (Cont."To Date" <= DateTo)
THEN
Cont.SETRANGE("Employee No.",Employee."No.");
IF Cont.FIND('-')
THEN
CurrReport.SKIP;
](*,)
Once again thanks a lot!
And what was the problem?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Cont.SETRANGE("Employee No.",Employee."No.");
Cont.SETFILTER("From Date",'>=%1',DateFrom);
Cont.SETFILTER("To Date",'<=%1',DateTo);
IF Cont.FIND('-')
THEN
CurrReport.SKIP;
Now the report only prints employees that are not found on the contributions within the specified date range....!
Thanks.....!
IF NOT Cont.ISEMPTY
RIS Plus, LLC