Skip to Content
author's profile photo Former Member
Former Member

How to add attachment to ARINVOICE using SAPBuisnessOneSDK


I'm working on data exportation from our product to SAP Buisness One using SAPBuisnessOneSDK.dll.

I try to export ARInvoice, APInvoice, SalesOrder and PurchaseOrder.

How can I add attachment to these type of documents so they reveal at attachment table?

Hope you can provide me with advice or some piece of code.

Waiting for the answer.

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • Best Answer
    Posted on Feb 22, 2017 at 06:43 PM

    Hi Alex,

    You need to use the Attachments2 object to insert attachments for SAP Business One and after this, reference the id of your attachment entry for your document.

    Below a sample:

    Attachments2 oAtt = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2);
                    string filename = @"C:\Users\diego.lother\Desktop\txt.txt";
                    if (File.Exists(filename))
                        oAtt.Lines.SourcePath = System.IO.Path.GetDirectoryName(filename);
                        oAtt.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(filename);
                        oAtt.Lines.FileExtension = System.IO.Path.GetExtension(filename).Substring(1);
                        oAtt.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES;
                        int attEntry = 0;
                        if (oAtt.Add() == 0)
                            attEntry = int.Parse(oCompany.GetNewObjectKey());
                            Documents oDoc = oCompany.GetBusinessObject(BoObjectTypes.oInvoices);
                            oDoc.CardCode = "C00000001";
                            oDoc.DocDueDate = DateTime.Now;
                            oDoc.DocType = BoDocumentTypes.dDocument_Service;
                            oDoc.Lines.ItemDescription = "Test";
                            oDoc.Lines.AccountCode = "";
                            oDoc.Lines.LineTotal = 100.00;
                            oDoc.AttachmentEntry = attEntry;
                            if (oDoc.Add() != 0)

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded