Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Transfer Data from a Temporary Table to a Normal Table

(0) ShareShare
ReportReport
Posted on by 372

Hello,

I have a table that calcs data into a temp table when it opens, however, I need to print some of this data based on if the user checks a box. I could not get a report to reference this data, so we agreed we needed a archive table anyway. So now I want to be able to archive the temp records into a normal table, then I can call a report for that. 

In short - how do I transferfields from a temp table to a non temp table?

Thanks,

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Transfer Data from a Temporary Table to a Normal Table

    Then you need to use Rec variable 

  • ChazKimRP Profile Picture
    ChazKimRP 372 on at
    RE: Transfer Data from a Temporary Table to a Normal Table

    The worksheet line is the temp table and the page was set to sourcetabletemp=true.

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Transfer Data from a Temporary Table to a Normal Table

    FP_FinanceWorksheetLine this variable doesn't seem like a temporary, if the worksheet page table is the source, then use that. You are creating a new variable which is not the temporary

  • ChazKimRP Profile Picture
    ChazKimRP 372 on at
    RE: Transfer Data from a Temporary Table to a Normal Table

    seems like it still is not working. It is not entering any data into the archive table.

    FP_WorksheetLine is the temp table that has the data in it I want to archive. The procedure to archive is on the Worksheet page. In the below snip i get no worksheet lines are found.

        procedure ArchiveFinanceOptions();
        var
        FP_FinanceWorksheetLine: Record FP_FinanceWorksheetLine;
        FP_FinanceOptionsArchive: Record FP_FinanceOptionsArchive;
        FP_FinanceOptionsArchiveList: Page FP_FinanceOptionsArchive;
        NextEntryNo: Integer;
        begin
            if FP_FinanceOptionsArchive.FindLast then
            NextEntryNo:=FP_FinanceOptionsArchive."Entry No.";

            FP_FinanceOptionsArchive.Reset;

            FP_FinanceWorksheetLine.SetRange(Modified,false);
            FP_FinanceWorksheetLine.SetFilter("Entry No.",'<>0');
            
            if FP_FinanceWorksheetLine.FindSet then repeat
            Error('found a worksheet line');
            FP_FinanceOptionsArchive.TransferFields(FP_FinanceWorksheetLine);
            FP_FinanceOptionsArchive."Entry No.":=NextEntryNo+1;
            FP_FinanceOptionsArchive.Insert;
            
            until FP_FinanceWorksheetLine.Next=0;
            Error('No Worksheet Lines Found');
        end;
    pastedimage1589559456885v1.png
  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Transfer Data from a Temporary Table to a Normal Table

    You cannot use GetRangeMax that way, you use that function when you specify the filter. Use find last to get the last entry no.

  • ChazKimRP Profile Picture
    ChazKimRP 372 on at
    RE: Transfer Data from a Temporary Table to a Normal Table

    Yea its not working I get this error. but im also pretty sure if i call the variable FP_FinanceWorksheetLine record it will be empty since thats a temp table.

    pastedimage1589378264414v1.png

        procedure ArchiveFinanceOptions();
        var
        FP_FinanceWorksheetLine: Record FP_FinanceWorksheetLine;
        FP_FinanceOptionsArchive: Record FP_FinanceOptionsArchive;
        FP_FinanceOptionsArchiveList: Page FP_FinanceOptionsArchive;
        NextEntryNo: Integer;
        begin
            NextEntryNo:=FP_FinanceOptionsArchive.GetRangeMax("Entry No.");

            FP_FinanceWorksheetLine.SetRange("Archive Line",true);
            
            if FP_FinanceWorksheetLine.FindSet then repeat
            FP_FinanceOptionsArchive.TransferFields(FP_FinanceWorksheetLine);
            FP_FinanceOptionsArchive."Entry No.":=NextEntryNo+1;
            FP_FinanceOptionsArchive.Insert;
            
            until FP_FinanceWorksheetLine.Next=0;
        end;
  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Transfer Data from a Temporary Table to a Normal Table

    You can just look through the temporary record set and use TRANSFERFIELDS or assign to create records. For ex:

    IF TempCustomer.FINDSET THEN

        REPEAT

         Customer.TRANSFERFIELDS(TempCustomer);

         Customer."No." := '';

         Customer.INSERT(TRUE);

        TempCustomer.NEXT  = 0;

    Regarding the report, you base a report based on the temporary table, you can use the Integer DataITem for it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,419 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,492 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans