PdcAttachmentList.ReadFromTableName
Declaration
ReadFromTableName(tableName as String, Id as string) as Boolean
Description
This function will read the attachments based on the TableName and Id string. All available properties will be filled in from the database/docrepo/sharepoint. The file will also be downloaded to a temp directory, and the location of this file will be available in the PdcAttachment.TempFilePath property. In the case of Sharepoint it will not copy the file if a local sharepoint folder is available, it will then put the local path in this property. So the file will always be available at the path stored in the PdcAttachment.TempFilePath property.
When reading attachments from Sharepoint, the PdcAttachment.FileName will include a full path towards the file. otherwise it will only include the filename without the full path.
Notes
Code example
This example loads all attachments related to calculationnumber 12345
Dim attachmentlist As PDCEXT.PdcAttachmentList = PDC.App.AttachmentList
if attachmentlist.ReadFromTableName("DO_CALC", "12345") then
if attachmentlist.Count > 0 then
For index = 0 to attachmentlist.count - 1
Dim attachment as PDCEXT.PDCAttachment = attachmentlist.Items(index)
Next
end if
end if
Copying all attachments of a calculation to a sales invoice
Dim calcAttachList As PDCEXT.IPdcAttachmentList = PDC.App.AttachmentList
calcAttachList.ReadFromTableName("DO_CALC", tbCalcNr.Text)
Dim invAttachList As PDCEXT.IPdcAttachmentList = PDC.App.AttachmentList
invAttachList.ReadFromTableName("FACTUUR", tbInvNr.Text)
For attachIndex As Integer = 0 To calcAttachList.Count - 1
Dim attachment = calcAttachList.Items(attachIndex)
Dim copyAttachment As PDCEXT.IPdcAttachment = invAttachList.Add
copyAttachment.FileName = attachment.FileName
copyAttachment.TempFilePath = attachment.TempFilePath
copyAttachment.Save("")
Next
Availability
Changed in 2022 R3