In C/U 80 (gb and W1 version) I have amended the PrintReport Section to read as follows: REPEAT ReportSelection.TESTFIELD(“Report ID”); CASE ReportUsage OF ReportSelection.Usage::“S.Invoice”: FileName:=STRSUBSTNO(‘c:%1 - %2.htm’,‘Invoice’,SalesInvHeader.“No.”); REPORT.SAVEASHTML(REPORT::“Email Invoice”,FileName,FALSE,SalesInvHeader); So, in the S&R module, I go to Invoices, create my invoice and “Post and print” However, I get an error once this has been executed : Sales Header does not exist Type=Invoice No.=SI12345 (where this is the last invoice no. used). This only happens when printing the report as HTML and I do NOT get the error when I do Report.run or Report.Runmodal. Also, I have had this working twice, but it seems to NOT work more than it works !!! Any Suggestions would be helpful as my head is about to explode.
I’m guessing that at this point you have already posted the Sales Header. The error you get (“Sales Header does not exist Type=Invoice No.=SI12345”) indicates that you are using a “Sales Header” when you should be using “Sales Invoice Header”. Therefore you should check that your SalesInvHeader variable is of the Subtype “Sales Invoice Header” and that the first dataitem in the “Email Invoices” report is also a “Sales Invoice Header”. Hope this helps. Stefan
quote:
I’m guessing that at this point you have already posted the Sales Header.
Yes
quote:
The error you get (“Sales Header does not exist Type=Invoice No.=SI12345”) indicates that you are using a “Sales Header” when you should be using “Sales Invoice Header”.
I too thought that this was the issue, however, I have copied the standard invoice (R206) and put Email at the top to make sure that this was not the case. Also, SalesInvHeader is the standard object used from the previous section (code I think it is) The main concern I have is this: Why does it work okay when doing Report.Run or Report.Runmodal but NOT when I do Report.SAVEASHTML and why will it work about 5% of the time but then something happens and it all comes to a grinding halt ???
Just a bit of extra info… I have had a call from MSB uk (Navision) and this is a known bug. [:0] Aparently, you cannot call the codeunit as a run object, you need to define this in c/al. Unfortunately, i tried this, and I still get the same error.[:(!] I will update as soon as I know anything more [:(]
Ok, I have the solution: Instead of using the runobject call the following code behind the menu object: CurrForm.“No.”.ACTIVATE;//this line changes the focus to the sales header CODEUNIT.RUN(CODEUNIT::“Sales-Post + Email”,Rec);//Call is still within the codeunit to SAVEASHTML The error was caused as the focus remained on the sales line and the sales line was calling the GETSALESHEADER function. The informaion that was being called has now been removed due to the SalesPost.Run codeunit. I don’t know if Im supposed to write m own replies, but I thought it may be of use ???
So you did get an error with Report.run or Report.Runmodal and not only with saveashtml.
quote:
So you did get an error with Report.run or Report.Runmodal and not only with saveashtml.
No, only with Report.SAVEASHTML