table 60030 SalesInvoiceCreditTemp { Caption = 'Sales Invoice & credit Temp'; [b] TableType = Temporary[/b];//Not working fields { field(60010; Key1; Integer) { Caption = 'Key'; AutoIncrement = true; } field(60020; DocumentType; Code[20]) { Caption = 'Document Type'; } field(60030; DocumentNo; code[50]) { Caption = 'Doc No.'; } field(60040; PostingDate; Date) { Caption = 'Posting Date'; } field(60050; ExternalNo; Text[200]) { Caption = 'Extenral No'; } field(60060; CustomerCode; code[50]) { Caption = 'Customer Code'; TableRelation = Customer; } field(60061; CustomerName; Text[200]) { Caption = 'Customer Name'; TableRelation = Customer.Name; } } keys { key(PK; DocumentType, DocumentNo) { Clustered = true; } key(Key2; CustomerName, PostingDate) { } } }
report 60030 CustomerItemSales { DefaultLayout = RDLC; RDLCLayout = 'CustomerItemSales.rdlc'; ApplicationArea = Basic, Suite; Caption = 'Customer Item Sales'; PreviewMode = PrintLayout; UsageCategory = ReportsAndAnalysis; DataAccessIntent = ReadOnly; Permissions = TableData SalesInvoiceCreditTemp = rimd; dataset { dataitem(SalesTemp; SalesInvoiceCreditTemp)//*Temp* { DataItemTableView = sorting(CustomerName, PostingDate); RequestFilterHeading = 'Sales'; column(ReportName; 'Customer Sales by Item') { } column(SalesBufferFIlter; SalesBufferFIlter) { } column(StartingDate; FromDate) { } column(EndingDate; ToDate) { } column(DocumentType; DocumentType) { } column(CustomerCode; CustomerCode) { } column(CustomerName; CustomerName) { } trigger OnPreDataItem() var SalesTempTbl: Record SalesInvoiceCreditTemp; SalesInvHdr: Record "Sales Invoice Header"; begin SalesTempTbl.DeleteAll(); SalesTempTbl.Init(); begin//*INVOICE SalesInvHdr.Reset(); SalesInvHdr.SetRange("Posting Date", FromDate, ToDate); if SalesInvHdr.FindSet() then repeat SalesTempTbl.DocumentType := '1INV'; SalesTempTbl.DocumentNo := SalesInvHdr."No."; SalesTempTbl.PostingDate := SalesInvHdr."Posting Date"; SalesTempTbl.CustomerCode := SalesInvHdr."Sell-to Customer No."; SalesTempTbl.CustomerName := SalesInvHdr."Sell-to Customer Name"; SalesTempTbl.Insert(); until SalesInvHdr.Next() = 0; end; end; } } requestpage { SaveValues = true; layout { area(content) { group(Options) { Caption = 'Date Range'; field(StartingDate; StartingDate) { ApplicationArea = All; Caption = 'Starting Date'; ToolTip = 'Specifies the date when you want the report to start.'; } field(EndingDate; EndingDate) { ApplicationArea = All; Caption = 'Ending Date'; ToolTip = 'Specifies the date when you want the report to end.'; } } } } } trigger OnPreReport() var FormatDocument: Codeunit "Format Document"; begin CompanyInformation.Get; SalesBufferFIlter := SalesTemp.GetFilters; FromDate := StartingDate; ToDate := EndingDate; IF (StartingDate = 0D) OR (EndingDate = 0D) THEN ERROR('Start Date and End Date are Mandatory'); end; var StartingDate: Date;//check FromDate: date; EndingDate: date; ToDate: date; CompanyInformation: Record "Company Information"; Text000: Label 'Period: %1'; Item: Record Item; SalesBufferFIlter: TExt; }
Answers
Solution is to remove "SalesTempTbl" as a variable and replace it in code with "SalesTemp". Then you will be inserting records into the correct instance of your table