Skip to Content
0

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

Dec 12, 2016 at 04:34 PM

87

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Pedro Magueija Dec 13, 2016 at 07:50 PM
1

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

Share
10 |10000 characters needed characters left characters exceeded