OnInitReport doesn't work as expected

wic
Member Posts: 96
hi all,
I'm working on a 5.00 (6.00.32012) in a classic env.
The OnInitReport() doesn't work as expected because it's triggering only the first time I run it after a save&compile.
Explanation: I set the number of copies that (should) appears on the request form in my OnInit trigger.
REPORT - OnInitReport()
NoOfCopies=5
then I save/compile and run the report. The RequestForm shows NoOfCopies = 5
I modify this value to 0 and esc the report.
Run the report again, the value of NoOfCopies = 0 ](*,) where is my 5?
are ZUP informations loaded AFTER the Init?
If I design the report, save&compile, run, then it works!
I'm very :?
I'm working on a 5.00 (6.00.32012) in a classic env.
The OnInitReport() doesn't work as expected because it's triggering only the first time I run it after a save&compile.
Explanation: I set the number of copies that (should) appears on the request form in my OnInit trigger.
REPORT - OnInitReport()
NoOfCopies=5
then I save/compile and run the report. The RequestForm shows NoOfCopies = 5
I modify this value to 0 and esc the report.
Run the report again, the value of NoOfCopies = 0 ](*,) where is my 5?
are ZUP informations loaded AFTER the Init?
If I design the report, save&compile, run, then it works!
I'm very :?
#### Only one can survive ######
0
Answers
-
I usually program this kind of things in the onopenform of the requestpage, and works like a charm...
Anyway, if the onopenform method works (as i expect), i am still curious about the fact that the oninit doesn't work...maybe, as you said, it is overwritten by the setting of the property "savevalues" of the requestform (that are saved in the zup file).0 -
Belias wrote:...maybe, as you said, it is overwritten by the setting of the property "savevalues" of the requestform (that are saved in the zup file).
Doing it in OnOpenForm or probably also on OnInit of the Form does not run when you run the form without Requestform.
The settings in the zup will be loded related to the form.
So, you might have to initialize it twice, one time in OnInitReport and another time in OnOpenForm (or in OnInit of the form, depending on what you want to get).0 -
vaprog wrote:Doing it in OnOpenForm or probably also on OnInit of the Form does not run when you run the form without Requestform.
and if oninitform doesn't work, go for the onopenpage and onprereport triggers, it should be fine (depending on where you placed the rest of your code...i don't know if you have some fancy logic in the oninit)
0 -
Hi all,
NUmberofCopies is a field on the RequestForm, but it's set on the OnInit() trigger to 5 because it's desired so. #-o
In short: the problem comes form the property "SaveValues" of the RequestForm. This property has "priority" over the OnInit, or this part of functionality runs after the OnInit().
I understand this as:
1° Execute the OnInit trigger, (here I set my GlobalVar NumberOfCopies to 5)
2° Take the value saved last time (maybe from zup)
The second step has for effect to set NumberOfCopies back to the latest value. The first time I use it - after a save&Compile - it's null so it doesn't reset my value of 5 put by code.
Let's say I run the report... I overwrite manually the 5 by a 2, the system saves this 2 as default. So never again the 5 set by code will be used because the latest saved value is 2 so it has priority.
Solution: set property "SaveValues" to NO!
\:D/
Regards
noteToWebmasters:how do I put this post as "SOLVED"?#### Only one can survive ######0 -
wic wrote:noteToWebmasters:how do I put this post as "SOLVED"?0
-
Some clarification on "OnInitReport".
It is triggered when the report is initialized.
So when you do a REPORT.RUN[MODAL], it is triggered at that moment and each time you run the line of code.
If you have a report-variable, the first time you run the report, it OnInitReport-trigger is run but not the next times. At least until you 'destroy' the variable by closing the form (run by NOT using a form-variable!) or using CLEAR of the report.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions