I need to download all the attachments from all the tests within the test plan. I have a function that should do that and I need some advice with it.
I have posted the function that I have used to get all the attachments. I have tried retrieving the attachments based on a path that is given. I have tried changing the filter based on values I have found in the CROS_REF table, CR_REFERENCE field.
Public Function DownloadAttachments(TDFolderPath, sDownloadTo) Dim otaAttachmentFactory 'As TDAPIOLELib.AttachmentFactory Dim otaAttachment 'As TDAPIOLELib.Attachment Dim otaAttachmentList 'As TDAPIOLELib.List Dim otaAttachmentFilter 'As TDAPIOLELib.TDFilter Dim otaTreeManager 'As TDAPIOLELib.TreeManager Dim otaSysTreeNode 'As TDAPIOLELib.SysTreeNode Dim otaExtendedStorage 'As TDAPIOLELib.TreeManager Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Dim strPath 'As String Set otaTreeManager = QCUtil.TDConnection.TreeManager
Set otaSysTreeNode = otaTreeManager.NodeByPath(TDFolderPath) Set otaAttachmentFactory = otaSysTreeNode.Attachments Set otaAttachmentFilter = otaAttachmentFactory.Filter otaAttachmentFilter.Filter("CR_REFERENCE") = "'ALL_LISTS_" & otaSysTreeNode.NodeID & "_*'" Set otaAttachmentList = otaAttachmentFilter.NewList DowloadAttachments = "" If otaAttachmentList.Count > 0 Then For i = 1 to otaAttachmentList.Count
set otaAttachment = otaAttachmentList.Item(i)
otaAttachment.Load True, "" If (fso.FileExists(otaAttachment.FileName)) Thens
trFile = otaAttachmentList.Item(i).Name myarray = split(strFile,"ALL_LISTS_"& otaSysTreeNode.NodeID & "_")
fso.CopyFile otaAttachment.FileName, sDownloadTo & "\" & myarray(1)
Reporter.ReportEvent micPass, "File Download:", myarray(1) & " downloaded to " & sDownloadTo DownloadAttachments = sDownloadTo
end if Next Else
Reporter.ReportEvent micFail, "No attachments to download", _"No attachments found in specified folder '" & TDFolderPath & "'."DowloadAttachments = "Empty" End If Set otaAttachmentFactory = Nothing Set otaAttachment = Nothing Set otaAttachmentList = Nothing Set otaAttachmentFilter = Nothing Set otaTreeManager = Nothing Set otaSysTreeNode = Nothing Set fso = nothing End Function
Regardless of what (valid) path I have tried, the result is the same. It says that there are no attachments to download. I`m pretty sure the issue is in this piece of code:
Set otaAttachmentFilter = otaAttachmentFactory.Filter otaAttachmentFilter.Filter("CR_REFERENCE") = "'ALL_LISTS_" & otaSysTreeNode.NodeID & "_*'"
Also, if anyone has any advice over other approaches, any help would be gladly appreciated! Thank you