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.