Create QC Resource with uft

Clash Royale CLAN TAG#URR8PPP
Create QC Resource with uft
I found a lot of examples about uploading a resource to ALM via UFT.
However there were always a resource already created in ALM.
How can i create and upload a resource to ALM using UFT?
My problem is I don't know how many resources I am going to need, so I have to dinamically create resources and then upload them.
I do not want to upload files as attachments to the run.
Thank you
1 Answer
1
I think I found the answer here: http://www.codetweet.com/other/create-new-resource-almqc-using-ota/
Sub CreateNewResource(resourceFolderId As Integer, fileType As String, fileName As String, fileParentFolderPath As String)
On Error GoTo Errhandler:
'--- Represents a file or folder stored in the Quality Center repository
Dim resource As QCResource
'--- Represents a QC resource folder.
Dim resourceFolder As QCResourceFolder
'--- Services for managing QC resources.
Dim resourceFactory As QCResourceFactory
'--- Services for managing QC resource folders.
Dim resourceFolderFactory As QCResourceFolderFactory
'--- Services to manage resource storage.
Dim testResourceStorage As IResourceStorage
Dim resourceItem
Dim resourceFound As Boolean
' ***TDConn is TDConnection class object.Create this object before using this function.
Set resourceFolderFactory = TDConn.QCResourceFolderFactory
Set resourceFolder = resourceFolderFactory.Item(resourceFolderId)
Set resourceFactory = resourceFolder.QCResourceFactory
Set currResourceList = resourceFactory.NewList("")
For ItemCount = 1 To currResourceList.Count
currItem = currResourceList.Item(ItemCount).Name
If UCase(currItem) = UCase(fileName) Then
Set resourceItem = currResourceList.Item(ItemCount)
resourceFound = True
Exit For
End If
Next
If Not resourceFound Then
'--- Create a resource
Set resourceItem = resourceFactory.AddItem(fileName)
resourceItem.ResourceType = fileType
resourceItem.fileName = fileName
resourceItem.Post
'--- Check if the resources added successfully
Set currResourceList = resourceFactory.NewList("")
For ItemCount = 1 To currResourceList.Count
currItem = currResourceList.Item(ItemCount).Name
If UCase(currItem) = UCase(fileName) Then
resourceFound = True
Exit For
End If
Next
If resourceFound Then
'--- Attach the file to resource
resourceItem.vC.CheckOut ""
Set testResourceStorage = resourceItem
testResourceStorage.UploadResource fileParentFolderPath, False
resourceItem.vC.CheckIn "Automated check-in by utility" & Now
Else
oFile.WriteLine ("Recently added new resource not found on ALM.Try again later.")
Exit Sub
End If
Else
resourceItem.vC.CheckOut ""
Set testResourceStorage = resourceItem
testResourceStorage.UploadResource fileParentFolderPath, False
resourceItem.vC.CheckIn "Automated check-in by utility" & Now
End If
Set resourceFolderFactory = Nothing
Set resourceFolder = Nothing
Set resourceFactory = Nothing
Set currResourceList = Nothing
Exit Sub
Errhandler:
MsgBox("Error Executing - `CreateNewResource` ; Error Uploading file " & fileName)
Exit Sub
End Sub
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.