Hello there,
I have an Report, which need an "OnInit Report - Trigger".
The Trigger looks like:
IF Rezeptzähler.Nr >= 99700
THEN
MESSAGE ('Bitte Info an die IT!');
But in my Report the "OnInit Report" do not have the Value from my Table "Rezeptzähler".
The Report get the Number when i print it, but then it is to late..
Can somone please tell me, how the Report get the Value from the Table, when the Report is opened?
Thank you!
Best wishes
Steffen
Answers
The first time the report "sees" the data in the table is in OnAfterGetRecord.
Filter however are setup in OnPreDataItem, so you can add a FINDSET to OnPreDataItem to prefetch the record if you need your data earlier.
If you need to have some data available earlier than that you need to created a function on the report, create report variable and create that function to pass required data before calling ReportVar.RUN()
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
But i did not completly understand how I do that..
My table called „Rezeptzähler“ and the Field I need called „Nr“. So what is the code I put in my „OnInit Report“? So that the Report will Show a Message if the Field „Nr“ in the Table „Rezeptzähler“ is bigger than 99700?
Thanks
In the report create a table variable of the same type as your data item (Rezeptzähler)
Then in In OnPreDataItem do this:
Note: If you use MESSAGE the system will show the message and will print the report anyway - regardless where you put your code. If you want to prevent the report from being printed you need to use the ERROR in OnPreDataItem.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Thanks
I made it like wolfskin said, and it works great!
I have now an Variable called "RezeptzählerRec" and in my "OnInitReport" is the following Code:
The Report will now show the Message "Bitte Info an die IT", and when it is on 99999 then The Error will show up and the Report can not be oben.
Thank you very much!