PAGE.Runmodal creating records in Gen. Journal Line table
spider1269
Member Posts: 78
I have a custom code unit "AssignAllocations" that was working fine in 5.0 but is now causing odd behavior in NAV2015. Within the Purchase Journal I'm calling "AssignAllocations" with a GenJnlLine VAR that runs the following code:
When the PAGE.RUNMODAL executes it creates a new record in the Purchase Journal that is a near duplicate of the record above it. If I change the code to PAGE.RUN it doesn't create the duplicate record. The GenJnlLine variable is the record that is duplicating. The page is # 254 and is set to DelayedInsert = YES. The codeunit "AssignAllocations" is called before the record is inserted.
Some of the things I've tried that fix the issue:
Commenting out the GenJnlLine.MODIFY - creates only single line.
Changing PAGE.RUNMODAL to PAGE.RUN - creates only single line.
In the Purchase Journal if I move off the record before executing the AssignAllocations code unit - creates only single line.
I have a work around but I've never seen this before and I'd like to figure out why it's doing what it is.
WITH GenJnlAlc DO BEGIN
- other code, etc. -
GenJnlLine."Sales/Purch. (LCY)" := GenJnlLine.Amount;
GenJnlLine.MODIFY;
SETRANGE("Journal Template Name",GenJnlLine."Journal Template Name");
SETRANGE("Journal Batch Name",GenJnlLine."Journal Batch Name");
SETRANGE("Journal Line No.",GenJnlLine."Line No.");
PAGE.RUNMODAL(284,GenJnlAlc);
END;
When the PAGE.RUNMODAL executes it creates a new record in the Purchase Journal that is a near duplicate of the record above it. If I change the code to PAGE.RUN it doesn't create the duplicate record. The GenJnlLine variable is the record that is duplicating. The page is # 254 and is set to DelayedInsert = YES. The codeunit "AssignAllocations" is called before the record is inserted.
Some of the things I've tried that fix the issue:
Commenting out the GenJnlLine.MODIFY - creates only single line.
Changing PAGE.RUNMODAL to PAGE.RUN - creates only single line.
In the Purchase Journal if I move off the record before executing the AssignAllocations code unit - creates only single line.
I have a work around but I've never seen this before and I'd like to figure out why it's doing what it is.
0
Best Answer
-
after call of GenJnlLine.MODIFY;
add a record reload using GenJnlLine.get(...)
then on the next lines you use this current, modified record
otherwise you create a new one.best regards
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/5
Answers
-
after call of GenJnlLine.MODIFY;
add a record reload using GenJnlLine.get(...)
then on the next lines you use this current, modified record
otherwise you create a new one.best regards
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/5 -
Thanks Jonathan. I had already tried that thinking it was a record version issue but that didn't fix it. The odd thing is I did a code trace between 5.0 and NAV2015 and not one line of code changed but the output did (second line gets created).0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
