Options

Get Records from SubPage based on a Temporary Table

JustJoshJustJosh Member Posts: 4
Hi,

I have created a Wizard page, in Dynamics NAV 2017.
The Wizard has a few steps, and one of them shows a SubPage where the Source Table is Temporary.

The user will fill in multiple Lines in this SubPage, and at the end of the Wizard we do some validation checks, then insert these records into the real table.
I am struggling with how to retrieve these Temp records stored in the subpage.

Is there a way to do this?

I have tried the following, and it only returns the last record the user enters, the previous records are not found.
On the Temp SubPage, I have added a function called "GetTempRecords(VAR "TempTable")" (I am replacing the real table names here for the example).

This function essentially does the following:
IF Rec.FINDSET THEN 
  REPEAT
    TempTable := Rec;
    TempTable.INSERT;
  UNTIL Rec.NEXT = 0;

I am then calling this from the Wizard Page, with the following line of code...
CurrPage.TempSubPage.PAGE.GetTempRecords(TempTable);

I used the VAR parameter, in the hope it would return all the records the user has entered.
When I debug, the line "Rec.FINDSET" only finds the last record entered, and I have tried adding "RESET" before but this didn't help.

Is there a better way to do this?


Best Answers

  • Options
    JustJoshJustJosh Member Posts: 4
    Answer ✓
    Managed to solve this, just in case anyone else is wondering...

    the function "GetTempRecords(VAR "TempTable") needed to use COPY(Rec, TRUE);
    IF FINDSET THEN 
      REPEAT
        TempTable.COPY(Rec, TRUE);
        TempTable.INSERT;
      UNTIL NEXT = 0;
    
  • Options
    JustJoshJustJosh Member Posts: 4
    Answer ✓
    Just in case anyone else needs to know it wasn't the code that was the problem.. It was because i was using a page as the subform. As soon as i changed this to ListPart it worked fine!

Answers

  • Options
    JustJoshJustJosh Member Posts: 4
    Answer ✓
    Managed to solve this, just in case anyone else is wondering...

    the function "GetTempRecords(VAR "TempTable") needed to use COPY(Rec, TRUE);
    IF FINDSET THEN 
      REPEAT
        TempTable.COPY(Rec, TRUE);
        TempTable.INSERT;
      UNTIL NEXT = 0;
    
  • Options
    JustJoshJustJosh Member Posts: 4
    Answer ✓
    Just in case anyone else needs to know it wasn't the code that was the problem.. It was because i was using a page as the subform. As soon as i changed this to ListPart it worked fine!
Sign In or Register to comment.