Form trigger for when refresh/update?

ccbryan63
Member Posts: 115
Is there a form trigger that fires when the form is refreshed or updated?
I have added a "Total Amount" field to Form 256 Payment Journal. When the batch name is chosen in the combo box, the screen does a setrange on the General Journal Line table. I have a little piece of code that sums the Amounts of the displayed records to the variable that is the source code of the "Total Amount" field. But I can't find a trigger to put the code in. If I put it in form.OnOpen() it works, and displays the total amount of the batch that the form defaults to, but I can't find a trigger that runs the code when the batch is changed.
Putting the code in the OnValidate and OnAfterValidate of the batch combo box doesn't work.
Any suggestions?
I have added a "Total Amount" field to Form 256 Payment Journal. When the batch name is chosen in the combo box, the screen does a setrange on the General Journal Line table. I have a little piece of code that sums the Amounts of the displayed records to the variable that is the source code of the "Total Amount" field. But I can't find a trigger to put the code in. If I put it in form.OnOpen() it works, and displays the total amount of the batch that the form defaults to, but I can't find a trigger that runs the code when the batch is changed.
Putting the code in the OnValidate and OnAfterValidate of the batch combo box doesn't work.
Any suggestions?
0
Answers
-
OnAfterGetRecord should do it. If the form is somehow refreshed, then navision 'gets' the record again from the DB, hence OnAfter'Get'Record.
-a0 -
Globals: JournalAmt type Decimal
On Trigger AddOnAfterGetCurrRecord() UpdateSums;
Create FunctionUpdateSums() BEGIN GenJnlLine.COPY(Rec); GenJnlLine.CALCSUMS(Amount); JournalAmt := GenJnlLine.Amount; END
Add text box at bottom of the form
SourceExp : JournalAmt
If I remember correctly you need to then add a SumIndexField(Amount) to one of the keys of the Gen Journal Line table0 -
I ended up taking care of it with a timer. Kluge maybe but it works like a charm.
Form TimerInterval property = 1 GJL = new global record variable Gen Jnl Line Form OnTimer() trigger: TotAmount := 0; GJL.SETRANGE("Journal Template Name","Journal Template Name"); GJL.SETRANGE("Journal Batch Name","Journal Batch Name"); IF GJL.FIND('-') THEN BEGIN REPEAT TotAmount := TotAmount + Amount UNTIL GJL.NEXT = 0; CurrForm.UPDATE(FALSE); END;
(I had forgotten the CALCSUMS function :oops: )
Just for grins I tried putting this code in OnAfterGetRecord and I got an error: "There is insufficent memory (stack) to execute this operation. This can be due to the way recursive function calls are used in the program." So then I put Savatage's code in OnAfterGetRecord and got the same message, so guess I'm sticking with my messy(?) solution.0 -
ccbryan63 wrote:So then I put Savatage's code in OnAfterGetRecord and got the same message, so guess I'm sticking with my messy(?) solution.
That is the exact code I use and it's the OnAfteGetCurrRecord Trigger.
Works fine
here's the old orig post
http://www.mibuso.com/forum/viewtopic.php?t=76920
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