cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

pedro_magueija
Active Contributor

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 
com_service.UpdatePathAdmin(oPathAdmin);

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

Pedro Magueija

LinkedIn | Twitter | Blog