PdcAttachment.Save

From External Bemet Wiki
Revision as of 11:00, 29 November 2023 by TC (talk | contribs)
Jump to navigation Jump to search

Declaration

Save(FilePath as String) as Boolean

Description

This function locates saves the attachment in Bemet

Notes

If the FilePath is an empty string, then it is assumed that the file is located in the Bemet temp directory. In this case the Attachment.FileName is used to locate the file in the temp directory and to load this file in a steam, before it is saved in the Document Repository, Sharepoint, or the attachment table.
If the FilePath is not empty, it will assume that it contains a full path to the file that you want to save. In this case the path should contain both the filepath and the filename.

When using Sharepoint, if this file already exists for the specific entity you are copying to ( for example calculation 12345 already has a drawing.pdf, and you are uploading another drawing.pdf) then it will overwrite this file in the sharepoint folder.


Code example

This example adds a new text file from a specific path to calculationnumber 12345

Dim attachmentlist As PDCEXT.PdcAttachmentList = PDC.App.AttachmentList
if attachmentlist.Read("DO_CALC", "", "12345") then
  dim attachment = attachmentlist.add
  attachment.Save("C:\test.txt")
end if

This example adds a new text file from the Bemet temp directory to calculationnumber 12345

Dim attachmentlist As PDCEXT.PdcAttachmentList = PDC.App.AttachmentList
if attachmentlist.Read("DO_CALC", "", "12345") then
  dim attachment = attachmentlist.add
  attachment.filename = "test.txt"
  attachment.Save("")
end if