Using temporary records

jorgitojorgito Member Posts: 115
Hi all.

I have a form called Form1 that has a button that opens a new form Form2 using a temporary record:
Form2.SETTABLEVIEW(Record2);
Form2.LOOKUPMODE(TRUE);
Form2.RUNMODAL;
where Record2 is a temporary record.

Inside Form2, I have a button that opens another form Form3.
Form3.Set(Rec);
Form3.LOOKUPMODE(TRUE);
Form3.RUNMODAL;

I have a Set function in Form3 that copies the original Record2 to a global variable Record3 inside Form3.
Set(VAR TempRec : TEMPORARY Record "Record")
Record3 := TempRec;

When the user selects a few lines in Form3, I want to enter some lines in Record2. So, I have the following code to fill in Record3 which is mapped to Record2 in Form2
LocalRec.COPY(Rec);
CurrForm.SETSELECTIONFILTER(LocalRec);
IF LocalRec.FIND('-') THEN
REPEAT
  Record3.INIT;
  ....
UNTIL LocalRec.NEXT = 0;

However, the above code does not work.

How can I use a temporary record of one form in another form??

Any ideas?

Jorgito

Comments

  • ara3nara3n Member Posts: 9,257
    I can tell you that the set function will not work
    You need to loop through it and insert it into record3.

    Set(VAR TempRec : TEMPORARY Record "Record")
    if TempRec.find('-') then repeat
    Record3 := TempRec;
    Record3.insert;
    until TempRec.next = 0;
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • jjanauskasjjanauskas Member Posts: 49
    ara3n is right, that record assignment does not assign a reference of another records.. it just copies the values of one record fields to another.

    But I also see a problem with the following code
    Form2.SETTABLEVIEW(Record2); 
    Form2.LOOKUPMODE(TRUE); 
    Form2.RUNMODAL; 
    

    where Record2 is temporary record.

    In this code the form will open just with FILTERS of Record2, but not with ENTRIES from Record2. If you want to open form with temporary record entries, you must use this code (as far as I remember):

    form.runmodal(<form ID>, <record>)

    where <record> is temporary record.
  • jorgitojorgito Member Posts: 115
    Actually,

    my problem is when the user selects a few records in Form3 and hits OK, the following code
    LocalRec.COPY(Rec);
    CurrForm.SETSELECTIONFILTER(LocalRec);
    IF LocalRec.FIND('-') THEN
    REPEAT
      Record3.INIT;
      ....
      Record3.INSERT;
    UNTIL LocalRec.NEXT = 0; 
    

    does not insert the records into Record3 (Record2 in Form2). So when Form3 closes and the user returns to Form2, the records are not there.

    I tried changing the tables to Non-temporary and everything works fine. However, they must be temporary, so that whenever many users work on the same table, each gets his own working space.

    And, by the way, the code
    Form2.SETTABLEVIEW(Record2);
    Form2.LOOKUPMODE(TRUE);
    Form2.RUNMODAL; 
    
    works fine.
  • ara3nara3n Member Posts: 9,257
    Did you change the set function the way I suggested?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.