Hi All,
Please help me with an issue...My cust wants the sales invoice report to be saved in the computer once the report is generated for an invoice...i tried to do it but i have a problem now...i can generate and store the report as .htm file using the method SAVEASHTML()...but its taking long time and i am also getting an error while storing ....I am posting the code and the error message .... please tell me ware i went wrong..
Code:
Filename := 'C:\FileAttachment\' + "Sales Invoice Header"."No." + '.htm';
SalesInvoiceHeader.RESET;
SalesInvoiceHeader.SETFILTER(SalesInvoiceHeader."No.", "Sales Invoice Header"."No.");
IF SalesInvoiceHeader.FIND('-') THEN BEGIN
SalesInvoiceLine.RESET;
SalesInvoiceLine.SETFILTER(SalesInvoiceLine."Document No.",SalesInvoiceHeader."No.") ;
IF SalesInvoiceLine.FIND('-') THEN BEGIN
CLEAR(Rep);
Rep.SETTABLEVIEW(SalesInvoiceHeader);
Rep.SETTABLEVIEW(SalesInvoiceLine);
OK := Rep.SAVEASHTML(Filename);
END;
END;
ERROR:
There is insufficient memory to execute this function.This can be caused by recursive function calls that are used in the program. Contact your system administrator
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I tried removing the line filter and kept only the Header Filter... but still its the same ... I tried writing the code in the "onpostreport " but the thing is after adding the code the "onpostreport " is running for the entire header table record...hence it takes long time and i amgetting the error...
The modified code is:
IF Counter = 0 THEN BEGIN
Filename := 'C:\FileAttachment\' + "Sales Invoice Header"."No." + '.htm';
//SalesInvoiceHeader.RESET;
SalesInvoiceHeader.SETFILTER(SalesInvoiceHeader."No.", "Sales Invoice Header"."No.");
IF SalesInvoiceHeader.FIND('-') THEN BEGIN
Counter += 1;
CLEAR(Rep);
Rep.SETTABLEVIEW(SalesInvoiceHeader);
OK := Rep.SAVEASHTML(Filename);
END; SalesInvoiceHeader.RESET;
END;
You cannot call the same report from within the report, without any condition which will end this endless loop... (endless recursion)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I tried copying the code into a codeunit and called the codeunit from the "onpostreport " of the sales invooice report...but its still its the same ](*,) ....please help me how i can fix it [-o< ....where should i call this codeunit...
:?:
It still is a infinite loop.
You can add a function to your report called don't run the CU. The function will set a global CalledFromCU boolean to true.
you can wrap your CU with If not CalledFromCU then begin
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!