You should never put any type of processing code in any of the section triggers.
I would use FINDLAST on a separate variable, and I would put the code in one of the 'Pre' triggers. Then as you are processing the records I would put something in OnAfterGetRecord to compare the current record with the last record that you retrieved earlier.
Hi All,
How to determine if the current record is the last record from a table in report?
TIA
Andi
Hmm a lot of differnt opinions here. Personally I would put the code in the:
MyRec-OnPostDataItem section.
But this will only give you the last record based on what you filtered and what keys you set.
Perhaps this is what the user will need. Are you trying to find the last record based on the keys and filters set on the report? Or the last record on the table without keys or filters?
But this will only give you the last record based on what you filtered and what keys you set.
Perhaps this is what the user will need. Are you trying to find the last record based on the keys and filters set on the report? Or the last record on the table without keys or filters?
I think in most cases when someone runs a report and say last record, that means generally the last record that is accessed in that section.
Also it depends what they want to know the last record for. If its to do some processing and modify records, as Daniel suggests, then I prefer to put the code in OnPostDataItem. If on the other hand the person really just wants to print a line differently than the previous lines, then they are probably going completely the wrong way about it, and instead of knowing its the last record, they should just print either a footer, or something else most Navision standard and forget about coding it. Its common to see C++ and VB programmers that try to replicate Navision report functionality in Code because they are more comfortable that way.
I often see reports with code to group totals instead of using Navision's grouping feature.
For reporting purposes sometimes I want to get the last receipt date or the last entry no for purchase receipts. This way, I can see if something was backdated after I ran my financial reports.
I did create a report that did something similiar like this. So it really depends on what the user is looking for.
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I would use FINDLAST on a separate variable, and I would put the code in one of the 'Pre' triggers. Then as you are processing the records I would put something in OnAfterGetRecord to compare the current record with the last record that you retrieved earlier.
RIS Plus, LLC
Hmm a lot of differnt opinions here. Personally I would put the code in the:
MyRec-OnPostDataItem section.
But this will only give you the last record based on what you filtered and what keys you set.
Perhaps this is what the user will need. Are you trying to find the last record based on the keys and filters set on the report? Or the last record on the table without keys or filters?
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
Post data item is the answer of this.[/quote][/code]
For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
I think in most cases when someone runs a report and say last record, that means generally the last record that is accessed in that section.
Also it depends what they want to know the last record for. If its to do some processing and modify records, as Daniel suggests, then I prefer to put the code in OnPostDataItem. If on the other hand the person really just wants to print a line differently than the previous lines, then they are probably going completely the wrong way about it, and instead of knowing its the last record, they should just print either a footer, or something else most Navision standard and forget about coding it. Its common to see C++ and VB programmers that try to replicate Navision report functionality in Code because they are more comfortable that way.
I often see reports with code to group totals instead of using Navision's grouping feature.
I did create a report that did something similiar like this. So it really depends on what the user is looking for.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
Yes exactly, and it does seem that andihp has left the building.
LOL
Love the ask and run users. Let all the people beat the topic like a dead horse when he probably figured out the answer already on his own.
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book