Quantcast
Viewing all articles
Browse latest Browse all 14708

Re: How to make link existing defect option mandatory when changing the defect status to Duplicate

Hi Magesh,

 

it is a little bit more complicated than I thought. Given that the links are created prior to the intended post operation they still may be virtual. That's why "hasLinkage" is not working. 

I have changed your code and added some comments. Hope this helps.

 

Function Bug_CanPost
'On Error Resume Next
'do not use "fieldisModified" - the second attempt it is indeed not
'modified - the check is now done everytime the bug is posted.
'If you do it only for the case the status changes - the user might remove
'the link once the "Closed - Duplicate" status is successfully set.
If Bug_Fields("BG_STATUS").Value = "Closed - Duplicate" then
dim objBug
dim bgLinkable
dim bgLinkFact
dim linkList
dim aFilter
'Get bug object - a little bit optimized - no list necessary here
set objBug = TDConnection.bugFactory.Item(Bug_Fields("BG_BUG_ID").Value)
Set bgLinkable = objBug 'cast for interface
set bgLinkFact=bgLinkable.BugLinkFactory
'get only linked bugs
Set aFilter = bgLinkFact.Filter
aFilter.Filter("LN_ENTITY_TYPE") = "BUG"
'force refresh to get also the links created prior to the post operation
'those links may not have a DB entry yet
Set linkList = bgLinkFact.NewList("[force_refresh]"&aFilter.Text)
Bug_CanPost = true
'check the lenght of the list - if it's empty force the user to link a bug
if linkList.Count=0 then
Bug_CanPost = False
Msgbox "Please link the Original Defect through Linked Entities tab before Submit"
end if
set objBug = nothing
set bgLinkable = nothing
set bgLinkFact = nothing
set linkLst = nothing
set aFilter = nothing
End if
'On Error GoTo 0
End Function

 

PS: don't forget to remove the comments for error handling once you're finished the code.

 

Hope this helps :)


Viewing all articles
Browse latest Browse all 14708

Trending Articles