Skip to Content
avatar image
Former Member

SDK. C#. How can I redirect attachments to subdirectories?

Hello. I need redirect attachment files in subdirectory of shared attachments directory via C#. Business object Attachments2 provides only sourcePath field, but not trgtPath. Is it possible to overwrite trgtPath? Even if move the file, then the target path will be invalid. I need function such as "Change Path" in context menu of attachment. Thank you.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 13, 2016 at 07:50 PM

    Hi Roman,

    The attachments are always copied to the folder defined in SAP Business One as the attachment folder.

    From the SDK:

    "The Attachments2 object enables to copy files from a source folder to the Attachments folder that is defined through the application."

    You can define the attachments folder in the client, or using the PathAdmin object e.g.:

    // Get the path admin object  
    CompanyService com_service = DICompany.GetCompanyService(); 
    oPathAdmin = com_service.GetPathAdmin(); 
    // Set new paths 
    oPathAdmin.WordTemplateFolderPath = "c:\Documnets\Templates\"; 
    oPathAdmin.PicturesFolderPath = "c:\Documnets\Pictures\"; 
    oPathAdmin.AttachmentsFolderPath = "c:\Documnets\Data\"; 
    oPathAdmin.ExtensionsFolderPath = "c:\Documnets\Extention\"; 
    // Update paths 

    Note that you can't move the file afterward, otherwise the "link" will be broken.

    Pedro Magueija

    LinkedIn | Twitter | Blog

    Add comment
    10|10000 characters needed characters exceeded