admin 管理员组

文章数量: 1086019

I'm trying to save a Salesinvoice object in CompanyA Business central as a pdf file in blob storage and afterward save it as a attached document on a purchase order in CompanyB.

I have made a table which is visible for all company, and I try to save the pdf from CompanyA in blobfield.

This is my code:

procedure GetSalesOrderDocumentFromHB(var PurchaseHeader: Record "Purchase Header"): Boolean
    var
        PostedSalesInvoiceNo: Code[20];
        inss: InStream;
        outss: OutStream;
        Parameters: Text;
        Blob: record "TableBlob";


    begin
        PostedSalesInvoiceNo := PurchaseHeader."Vendor Invoice No.";
        if PostedSalesInvoiceNo <> '' then 
        begin
            postedSalesInvoice.ChangeCompany('CompanyA');
            if postedSalesInvoice.GET(PostedSalesInvoiceNo) then 
            begin
                                
                TempBlob.CreateOutStream(outss);
                    Blob.INIT;
                    //Rec.ID := 12;   
                    blob.ID := PostedSalesInvoiceNo;
                    blob.MyBlob.CREATEOUTSTREAM(outss);
                    Parameters := StrSubstNo('<?xml version="1.0" standalone="yes"?><ReportParameters name="NN Salgs - Faktura" id="50000"><DataItems><DataItem name="Sales Invoice Header">VERSION(1) SORTING(Field3) WHERE(Field3=1(%1))</DataItem></DataItems></ReportParameters>', PurchaseHeader."Vendor Invoice No.");
                
                Report.SaveAs(50000, Parameters, ReportFormat::Pdf, outss);
                
                    CopyStream(outss, inss);
                    blob.MyBlob.CREATEOUTSTREAM(outss);
                    
                    Blob.Insert(true);
           End;

本文标签:

Error[2]: Invalid argument supplied for foreach(), File: /www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm, Line: 58
File: /www/wwwroot/roclinux.cn/tmp/route_read.php, Line: 205, include(/www/wwwroot/roclinux.cn/tmp/view_template_quzhiwa_htm_read.htm)
File: /www/wwwroot/roclinux.cn/tmp/index.inc.php, Line: 129, include(/www/wwwroot/roclinux.cn/tmp/route_read.php)
File: /www/wwwroot/roclinux.cn/index.php, Line: 29, include(/www/wwwroot/roclinux.cn/tmp/index.inc.php)