Hi,
I'm fairly new to Navision Attain / C/Side code, and I'm having some difficulties.
When I run the following code, although there is more than 1 record which matches the criteria, it only brings back one record.
If "Payroll Ledger Entry"."Journal Batch Name" = 'OFFICE PR' then
"Payroll Ledger Entry".SETFILTER("Payroll Control Code",'%1|%2','OFFICE HOURS WORKED',
'HOUR SICK OFFICE')
Else
"Payroll Ledger Entry".SETFILTER("Payroll Control Code",'%1|%2','HOUR REG',
'HOUR SICK')
The user is supposed to enter in the Journal Batch name to either get records related to OFFICE PR or FIELD PR. Where am I going wrong? Please help. If I fail the If statement, then the else statement runs fine.
Help would be greatly appreciated, thanks.
-S.
Computers can figure out all kinds of problems, except the things in the world that just don't add up. - James Magary
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Believe it or not, that's the only C/Side code I've got for that report.
The only other filters are:
Earned Pay Cycle Term - Year
Earned Pay Cycle Period - a number, ie 24.
They're all supposed to be user input.
1. I run the report
2. I enter in 'OFFICE PR' for Journal Batch Name and '24' for Pay Cycle Period
3. The report looks for the relevant records
4. Only one record appears on the report.
When I run the report, with Earned Pay Cycle Period = 24, and comment out the entire "else" section along with the If, I get more than one record.
-S.
I think you should put the code onaftergetrecord this way
if "Payroll Ledger Entry"."Journal Batch Name" = 'OFFICE PR' then begin
if ("Payroll Ledger Entry".Payroll Control Code" = 'OFFICE HOURS ORKED') OR ("Payroll Ledger Entry".Payroll Control Code" = 'HOUR SICK OFFICE') then
Currreport.skip;
end else
if ("Payroll Ledger Entry"."Payroll Control Code" = 'HOUR REG') OR
("Payroll Ledger Entry"."Payroll Control Code" = 'HOUR SICK') then
Currreport.skip;
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Mmmmm, I Love the smell of Fresh Code in the afternoon.. =P~
Sorry - I Think I need a vacation :?
http://www.BiloBeauty.com
http://www.autismspeaks.org
I just tried putting it in the OnAfterGetRecord section per your advice, and it doesn't work - I get every single job code in the report regardless of what I type in for Journal Batch Name.
Savatage: Try going to Europe and drinking up a storm. That'll relax ya.
Everyone else: any other ideas? It still isn't working, grumble.
-S.
after your SETFILTER, put This shows the filters and the no. of records in it.
It is also possible that you have defined some filters in the "DataItemTableView"- or "DataItemLink"-properties.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
However, I did fix it - I put the code back in OnPreDataItem because in OnAfterGetRecord, it will always pull one wrong record in the report.
I also changed the filter to a Request Report checkmark field, and it definetly cleaned up really well.
Thanks for all your time guys (n' gals, if any).
-S.