Logen Watkins Absent Member.
Absent Member.
279 views

Streamlining Defect Transfer

Jump to solution
Is it possible to transfer Defects directly from one Quality Center Domain/Project to another Domain/Project?

Currently we are using the Excel add-in, going through the following process:
Make sure the right fields are shown in Project 1's QC.
Export Defects.
Open up that file, and then run a macro I wrote on the data to "transition" their Project 1's fields to Project 2's fields, and adding in additional fields that Project 2 may require that Project 1 did not.
Use the Add-in to export Defects from Excel into Project 2's QC.

This process works, but is tedious and requires that each person who wants to transfer a defect have installed the add-in, go through the setup process (assigning fields to columns), requires they change information if we change required fields...

Long story short -- it seems that it should be possible to do the same work that my Excel macro does (written in VB) inside of Quality Center, and transfer directly from one project to another. So if a user selects a Defect and, for example, changes Defect Status to "Transfer this Defect," then the Defect could be transferred to Project 2 and locked in Project 1, with no additional steps required by the user.


Thank you for your time!
0 Likes
1 Solution

Accepted Solutions
SreeKrishnan Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution

Well, I needed to do some changes on my old code.Here is one you can try out.

You can have this one under Project1 Customise, Workflow, Defect Module, Bug_FieldChange. The transfer will happen when you change the status of the defect to "Transfer" or any other value you want this to happen.

If FieldName = "BG_STATUS" Then
If Bug_Fields.Field("BG_STATUS").Value = "4.Transfer" Then

Dim tdb
dim Bfact

Set tdb = createobject("TDApiOle80.TDConnection.1")
tdb.InitConnectionEx "http://xxxxx/qcbin"
tdb.ConnectProjectEx "INST_Domain2","Project2
","admin","password"

set bfact = tdb.bugfactory
set newbug = bfact.additem("")
newbug.field("BG_SUMMARY")= Bug_Fields.Field("BG_SUMMARY").Value
newbug.field("BG_STATUS")= Bug_Fields.Field("BG_STATUS").Value
newbug.field("BG_DETECTED_BY")= Bug_Fields.Field("BG_DETECTED_BY").Value
newbug.field("BG_RESPONSIBLE")= Bug_Fields.Field("BG_RESPONSIBLE").Value
newbug.Post

tdb.DisconnectProject
tdb.ReleaseConnection
Set tdb = nothing

End If

End If


Note : You may need to add some additional script to avoid duplication incase the user does change the status more than once. Replace the values INST_Domain2,Project2,admin and password with your domain,project2, admin userid and admin password

View solution in original post

0 Likes
11 Replies
SreeKrishnan Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
I ahve done this scripting in one of my earlier assignments. I provided a custom button that will copy the defect from Project A to Project B. Are you looking for something similar ?
0 Likes
Logen Watkins Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
Yes, I am. I would need the ability to change values as appropriate (their value in Severity may read "1 - Critical" whereas mine may say "1 - Important"), as well as add a default value for fields they do not have (for example, putting my user name in a contact field).

If you have already done something similar, I would love to know how it works -- while I wrote the VB "transition macro" with no problem in Excel, I do not know what commands are available inside of QC to transfer a Defect from one project to another, say from
Domain: INST_Domain1
Project: Project1
to
Domain INST_Domain2
Project: Project2

Again, thanks so much for your time.
0 Likes
SreeKrishnan Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution

Well, I needed to do some changes on my old code.Here is one you can try out.

You can have this one under Project1 Customise, Workflow, Defect Module, Bug_FieldChange. The transfer will happen when you change the status of the defect to "Transfer" or any other value you want this to happen.

If FieldName = "BG_STATUS" Then
If Bug_Fields.Field("BG_STATUS").Value = "4.Transfer" Then

Dim tdb
dim Bfact

Set tdb = createobject("TDApiOle80.TDConnection.1")
tdb.InitConnectionEx "http://xxxxx/qcbin"
tdb.ConnectProjectEx "INST_Domain2","Project2
","admin","password"

set bfact = tdb.bugfactory
set newbug = bfact.additem("")
newbug.field("BG_SUMMARY")= Bug_Fields.Field("BG_SUMMARY").Value
newbug.field("BG_STATUS")= Bug_Fields.Field("BG_STATUS").Value
newbug.field("BG_DETECTED_BY")= Bug_Fields.Field("BG_DETECTED_BY").Value
newbug.field("BG_RESPONSIBLE")= Bug_Fields.Field("BG_RESPONSIBLE").Value
newbug.Post

tdb.DisconnectProject
tdb.ReleaseConnection
Set tdb = nothing

End If

End If


Note : You may need to add some additional script to avoid duplication incase the user does change the status more than once. Replace the values INST_Domain2,Project2,admin and password with your domain,project2, admin userid and admin password

View solution in original post

0 Likes
Logen Watkins Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
Thanks so much for that code -- I'm modifying and expanding it to suit my needs, but I had a specific question about Attachments. Is there a way to attach all attachments (if any) as I create this new defect?

Also, is there a place where I can find information on available commands/objects on my own, like a complete TD manual? I found some user guides but that's not really what I'm after.
0 Likes
Logen Watkins Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
I meant to mention this in my previous post, about the attachments:
I see that there is a field called "BG_ATTACHMENT"...but does that simply copy over the text description of attachments or the actual attachments themselves? I will need to transfer the actual attachment.
0 Likes
SreeKrishnan Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
Logen, You can find the OTA API Reference guide has good information about the TD Objecs. You can also find some exmaples in the QC Admin Guide.

The BG_ATTACHMENT field on the BUG Table is just a flag (Y,N)that indicates if the defect has a attachment or not. You may be able to use this flag to trigger a function within your workflow script to download the attachment from Project A and upload it to Project B.
0 Likes
Logen Watkins Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
It wouldn't seem that I would need to download a copy of the file and then upload it into Project2...can I not feed Attachment.Save the url to an attachment, possibly through DirectLink, for each attachment?

What I am thinking is something along the lines of:
(I have created a new defect called NewBug for Project2 and loaded all values for it by this point):

Dim BugFact As BugFactory
Dim bugObj As Bug
Dim attachFact As AttachmentFactory
Dim attachObj As Attachment
Dim FilePath As String

Set BugFact = tdc.BugFactory
'will this pull up Item X in Project2 instead of Project1? If so, how do I avoid this?
Set bugObj = BugFact.Item(Bug_Fields.Field("BG_BUG_ID").Value)
Set attachFact = bugObj.Attachments
Dim lst As TDAPIOLELib.list
Set lst = attachFact.NewList("")

For Each attachObj in lst
'Upload attachment from current location to Project2 defect
Next


Is there a way to implement what I'm asking for inside that For statement, or do I have to download a local copy of each attachment there?

If I must download local copies, using attachObj.Load, how do I then direct the .Save operation to my new defect?
0 Likes
SreeKrishnan Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
Logen,
I have not tried this out myself on the projects. You may need to use the .Post method to make the attachment to the new defect. Did you get hold of a copy of the OTA API reference. There is an example on how you can make an attachment to the new defect from a file location.


0 Likes
Logen Watkins Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
I've put some more work into this, and even contacted HP QC, but still no luck.

The problem all stems from my inability save attachments to my local hard drive from inside QC. I have tried using .Load and .Save, but I cannot Load from one project and save to another, not using any method I've found.

If I could simply be able to do something to the effect of
attachObj.Saveas FILENAME
and would therefore know where the attachment is saved, I could then, on the new project's attachment list, create a new object and set
newObj.Filename = FILENAME
like you can do with any other file on your hard drive. (In other words, if I create a new item and set .Filename = "C:\Temp\test.txt"
it would upload that file correctly.

unforunately using .Load True, Filepath
does not allow me to specify what that filepath is -- and I cannot use ...Filename = Filepath as I had hoped I might (since Filepath is an output variable).

Any other thoughts?
0 Likes
Highlighted
Knowledge Partner
Knowledge Partner

Re: Streamlining Defect Transfer

Jump to solution
Hi Logan,

I have created the integration between projects. My integration works like this. In some certains situation the defect is created in other specific project. The new defect is created as a copy with all information including attachments.

here is my part of code that I use for copying of attachments:

CreateIntBug = true
if cmybug.HasAttachment then
set atfact = mybug.Attachments
set catlist = cmybug.Attachments.NewList("")
for i = 1 to catlist.Count
set cmyattach = catlist.item(i)
set cexstrg = cmyattach.AttachmentStorage
LoadPath = GetTMPFolder
cexstrg.ClientPath = LoadPath
cexstrg.Load cmyattach.Name, true
LoadPathFile = LoadPath & "\" & cmyattach.Name
CreateIntBug = CreateAttachment(atfact,LoadPathFile,cmyattach)
next
If not CreateIntBug then msgbox "CreateIntBug: There is a problem with creating attachment in the integrated system."
end if

function GetTMPFolder
On Error Resume Next
Dim tf, fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.GetSpecialFolder(2)
GetTMPFolder = tf
On Error GoTo 0
end function

function CreateAttachment(atfact,LoadPathFile,cmyattach)
On Error Resume Next
CreateAttachment = true
Set myattach = atfact.AddItem(Null)
myattach.FileName = LoadPathFile
myattach.Type = cmyattach.Type
myattach.Description = cmyattach.Description
myattach.Post
myattach.Rename cmyattach.Name(1)
myattach.Post
On Error GoTo 0
end function

Description of variables and functions:
- cmybug: is the object of the source bug in the source project
- mybug: is the object of the new bug in the destination project
- catlist: is the list of the attachments that should be copied
- GetTMPFolder: is a function that finds the temp folder of the current user
- CreateAttachment: is a function that will create new attachment in the destination project also with description

But as you are writing. I did not find any possibility how to copy file without loading it to the local temp folder.

Hope this help.
0 Likes
Logen Watkins Absent Member.
Absent Member.

Re: Streamlining Defect Transfer

Jump to solution
Thanks very much to the both of you. After my last post I began trying to get the extended storage method to work -- once I saw Vladmir's code it all made sense! Turns out it was a simple error but not one that I could figure out.

Thanks again to both, I have my defects transferring as I would like now.
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.