Modify fields on form with temp rec

grouicgrouic Member Posts: 34
Hello,

EDIT : oops wrong place for my post, my Nav is 4 SP1. Can someone move it in the right location ?

Make a form working with a temp record is a great adventure. Thanksfully to this forum, I found many information to make something working correctly. I still have questions ...

Context : The request is modifying the accounting reversal process to allow fields modification before validating the reversal (like the Posting Date). I added variables on the form 179. Once the field is validated, the corresponding field is modifyed.

This form (179) is populated with a temp record
(T179 : FORM.RUNMODAL(FORM::"Reverse Entries",ReversalEntry);

In the OnOpenForm I added the following code to populate my temp variable ReversalEntry2
IF FIND('-') THEN
  REPEAT
    ReversalEntry2 := Rec;
    ReversalEntry2.INSERT;
  UNTIL NEXT = 0;
In the OnValidate of my "Posting Date" Variable field I added the code :
IF CONFIRM(TextConfirm01,FALSE,NewRevPostingDate) THEN BEGIN
  IF ReversalEntry2.FIND('-') THEN REPEAT
    ReversalEntry2."Posting Date" := NewRevPostingDate;
    ReversalEntry2.MODIFY;
  UNTIL ReversalEntry2.NEXT = 0;
END ELSE
  NewRevPostingDate := 0D;
and in OnFindRecord, OnNextRecord, OnModifyRecord
//OnFindRecord
ReversalEntry2 := Rec;
IF NOT ReversalEntry2.FIND(Which) THEN
    EXIT(FALSE);
Rec := ReversalEntry2;
EXIT(TRUE);

//OnNextRecord
ReversalEntry2 := Rec;
CurrentSteps := ReversalEntry2.NEXT(Steps);
IF CurrentSteps <> 0 THEN
  Rec := ReversalEntry2;
EXIT(CurrentSteps);

//OnModifyRecord
ReversalEntry2 := Rec;
ReversalEntry2.MODIFY(FALSE);
EXIT(FALSE);
All this stuff works correctly, but I still have a display problem : the whole field column is correctly updated except the current selected line (I have to click on another line an come back on the line to have the correct value displayed).
I try currform.UPDATE(FALSE) in many triggers, but no result.
1-) Is there any way to update my form ?

2-) I red in the forum some people are writing ReversalEntry2.COPY(Rec) instead of ReversalEntry2 := Rec in the OnFindRecord and OnNextRecord. The behaviour is not the same in my case, all lines are not updated correctly.
What is the result difference between the these two commands ?

Thx experts for your help !

Grouic

Comments

  • AdministratorAdministrator Member, Moderator, Administrator Posts: 2,499
    [Topic moved from 'Navision Attain' to 'NAV/Navision Classic Client' forum]
  • kinekine Member Posts: 12,562
    Hello,

    EDIT : oops wrong place for my post, my Nav is 4 SP1. Can someone move it in the right location ?

    Make a form working with a temp record is a great adventure. Thanksfully to this forum, I found many information to make something working correctly. I still have questions ...

    Context : The request is modifying the accounting reversal process to allow fields modification before validating the reversal (like the Posting Date). I added variables on the form 179. Once the field is validated, the corresponding field is modifyed.

    This form (179) is populated with a temp record
    (T179 : FORM.RUNMODAL(FORM::"Reverse Entries",ReversalEntry);

    In the OnOpenForm I added the following code to populate my temp variable ReversalEntry2
    Code: Select all
    IF FIND('-') THEN
    REPEAT
    ReversalEntry2 := Rec;
    ReversalEntry2.INSERT;
    UNTIL NEXT = 0;

    In the OnValidate of my "Posting Date" Variable field I added the code :
    Code: Select all
    IF CONFIRM(TextConfirm01,FALSE,NewRevPostingDate) THEN BEGIN
    IF ReversalEntry2.FIND('-') THEN REPEAT
    ReversalEntry2."Posting Date" := NewRevPostingDate;
    ReversalEntry2.MODIFY;
    UNTIL ReversalEntry2.NEXT = 0;
    END ELSE
    NewRevPostingDate := 0D;

    and in OnFindRecord, OnNextRecord, OnModifyRecord
    Code: Select all
    //OnFindRecord
    ReversalEntry2 := Rec;
    IF NOT ReversalEntry2.FIND(Which) THEN
    EXIT(FALSE);
    Rec := ReversalEntry2;
    EXIT(TRUE);

    //OnNextRecord
    ReversalEntry2 := Rec;
    CurrentSteps := ReversalEntry2.NEXT(Steps);
    IF CurrentSteps <> 0 THEN
    Rec := ReversalEntry2;
    EXIT(CurrentSteps);

    //OnModifyRecord
    ReversalEntry2 := Rec;
    ReversalEntry2.MODIFY(FALSE);
    EXIT(FALSE);

    All this stuff works correctly, but I still have a display problem : the whole field column is correctly updated except the current selected line (I have to click on another line an come back on the line to have the correct value displayed).
    I try currform.UPDATE(FALSE) in many triggers, but no result.
    1-) Is there any way to update my form ?

    2-) I red in the forum some people are writing ReversalEntry2.COPY(Rec) instead of ReversalEntry2 := Rec in the OnFindRecord and OnNextRecord. The behaviour is not the same in my case, all lines are not updated correctly.
    What is the result difference between the these two commands ?

    Thx experts for your help !

    Grouic


    Report this post

    Ad 1) Try to update the current rec from the temp in OnfterGetCurrRecord
    Ad 2) The difference is that COPY will copy all filters - it means it work correctly when user set filter on the form, than you need to apply same filter to the temp record, else the result will be wrong for user...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • grouicgrouic Member Posts: 34
    Hello,

    1) I tried to put a rec := ReversalEntry2; in the OnAfterGetCurrRecord() => no change

    2) You are right, the filters I put on the form are no more taken in account ](*,)
    I replaced the ReversalEntry2 := Rec; by ReversalEntry2.COPY(Rec); ... but the fields are no more updated on the form, except the last line (I noticed the line are re-sorted ...).

    I'll try other tests.

    Thx for the help

    Grouic
Sign In or Register to comment.