Highlighted
Huriz Valued Contributor.
Valued Contributor.
659 views

Copy Instance attachment to another Instance using workflow

Jump to solution

I need help for copy a instance attachment to another instance using ota api.

for do this easier, we will imagine that it has only 1 attachment file

 

I have 2 instances, with ID 1 and 2, instance with ID 1 has attachment, and i want to copy to the id 2 instance

 

objId1 = TDConnection.TSTestFactory.Item(1)

objId2 = TDConnection.TSTestFactory.Item(2)

objId1Attach = objId1.Attachments 

objId2Attach = objId1.Attachments

For Each AttI In objId1Attach .NewList("")
    objId2Attach .AddItem(AttI.Id)
    objId2Attach .Post
Next

 

but is not working. Could anyone help me or let me know What I have to do or what are the mandatory fields that I need to complete before "POST" the attachment?

 

regards

 

 

Hodei Urra
0 Likes
1 Solution

Accepted Solutions
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: Copy Instance attachment to another Instance using workflow

Jump to solution

Yes, when linking to defects you can use the ID. But attachments is another thing, because here we are talking about repository objects, and the way of referencing them are a lot more complicated.

You can't use SQL to download or upload the attachments. You will need to check the examples that I mentioned and use the OTA API.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
4 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: Copy Instance attachment to another Instance using workflow

Jump to solution

You are missing the "Set" keyword on the first two lines.

And you can't create copy the attachments by providing the original ID. The ID is a readonly property provided by the application. Adding an attachment to another object will create a new ID, even if the file it is referring to is the same.

So you will need to download the attachment to your client, then upload it as a new attachment to the other object. You should be able to find code examples in the forum and in the OTA reference help.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
0 Likes
Huriz Valued Contributor.
Valued Contributor.

Re: Copy Instance attachment to another Instance using workflow

Jump to solution

yes you are right, I missed put "set" at the beggining 

the example was for link defect to test instances, but I modified for do the example for the attachment files. Im not sure right now, but I can remember that we can link defects using the defect ID or/and the defect object (I repeat, im not sure at all)

It must be another way without download, maybe more dangerous, becuase we will need to use SQL query, but something must be ther.

I have seen when we copy a testset, the attachment files are copied too, so for this reason I was asking for this.

regards

 

Hodei Urra
0 Likes
Knowledge Partner Knowledge Partner
Knowledge Partner

Re: Copy Instance attachment to another Instance using workflow

Jump to solution

Yes, when linking to defects you can use the ID. But attachments is another thing, because here we are talking about repository objects, and the way of referencing them are a lot more complicated.

You can't use SQL to download or upload the attachments. You will need to check the examples that I mentioned and use the OTA API.

Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Huriz Valued Contributor.
Valued Contributor.

Re: Copy Instance attachment to another Instance using workflow

Jump to solution

I read to late , but I have arrived to your conclusion anfter some tries 😕

After create a new clean proyect for do some test and have good references in the database i have: 

- created a test set, created a instance, attached a screenshot

- created a new test set, created a new istance.

go to database and;

- in the sequences table, increment +1 the cros_ref value

- in the cros_ref table, insert a new row, with the corresponding values in each column 

- in the testcycl table, put the tc_column of the instance to "y"

- in the SMART_REPOSITORY_LOGICAL_FILE  table, insert a new row with the corresponding values in each column

------- Until here the attached was created in the alm logicaly,and alm view a attached file in the ALM instance --------

but I have arrived to the SMART_REPOSITORY_PHYSICAL_FILE table and here is when I have seen that all my before work has been for nothing.

As you said before.. OTA api, download the attached file and re-upload it is the only way for copy a attached file.

Thank you very much for your words @Jan Czajkowski

 

Hodei Urra
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.