PAGE.Runmodal creating records in Gen. Journal Line table

spider1269spider1269 Member Posts: 73
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:
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.

Best Answer

Answers

  • spider1269spider1269 Member Posts: 73
    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).
Sign In or Register to comment.