If deletedSimilarBugIds <> "" Then
If inStr(deletedSimilarBugIds, ",") Then '多个要删除的类似问题单
deletedSimilarBugIdList = Split(deletedSimilarBugIds, ",")
For i = 0 To Ubound(deletedSimilarBugIdList)
Set objBug = objBugFac.Item(deletedSimilarBugIdList(i))
objBug.Field("BG_USER_13") = replace(objBug.Field("BG_USER_13"), thisBugId, "")
objBug.Post
Next
Else
Set objBug = objBugFac.Item(deletedSimilarBugIds)
objBug.Field("BG_USER_13") = replace(objBug.Field("BG_USER_13"), thisBugId, "")
objBug.Post
End If
End If
'问题单1有类似问题单2,问题单1提交后,问题单2自动的更新类似问题单号为1
If inStr(similarBugIds, ",") or inStr(similarBugIds, ",") Then '有多个类似问题单
similarBugIdList = Split(similarBugIds, ",")
For i=0 To Ubound(similarBugIdList)
Set objBug = objBugFac.Item(similarBugIdList(i))
originalBugId = objBug.Field("BG_USER_13")
If inStr(originalBugId, thisBugId)=False Then
If originalBugId <> "" Then
objBug.Field("BG_USER_13") = originalBugId& "," &thisBugId
Else
objBug.Field("BG_USER_13") = thisBugId
End If
objBug.Post
End If
Next
ElseIf similarBugIds <> "" Then '只有一个类似问题单
Set objBug = objBugFac.Item(similarBugIds)
originalBugId = objBug.Field("BG_USER_13")
If inStr(originalBugId, thisBugId)=False Then
If originalBugId <> "" Then
objBug.Field("BG_USER_13") = originalBugId& "," &thisBugId
Else
objBug.Field("BG_USER_13") = thisBugId
End If
objBug.Post
End If
End If作者: better_future 时间: 2016-1-26 12:56
' 获取已删除的类似问题单号
Function getDeletedSimilarBugId(bugId)
On Error Resume Next
Dim objBugFactory, objBug, objBugHistList
Dim currentSimilarBugIds, preSimilarBugIds
Dim similarBugIdList
getDeletedSimilarBugId = ""
Set objBugFactory = TDConnection.BugFactory
Set objBug = objBugFactory.Item(bugId)
Set objBugHistList = objBug.History.NewList("")
'获取当前的类似问题单号
For i=1 To objBugHistList.Count+1
If objBugHistList(i).FieldName = "BG_USER_13" Then
currentSimilarBugIds = objBugHistList(i).NewValue
Exit For
End If
Next
'获取之前的类似问题单号
For j=i+1 To objBugHistList.Count+1
If objBugHistList(j).FieldName = "BG_USER_13" Then
preSimilarBugIds = objBugHistList(j).NewValue
Exit For
End If
Next
'获取已经删除的类似问题单号
If inStr(preSimilarBugIds, ",") Then
similarBugIdList = Split(preSimilarBugIds, ",")
For i = 0 To Ubound(similarBugIdList)
If inStr(currentSimilarBugIds, similarBugIdList(i))= False Then
If getDeletedSimilarBugId = "" Then
getDeletedSimilarBugId = similarBugIdList(i)
Else
getDeletedSimilarBugId = getDeletedSimilarBugId & "," &similarBugIdList(i)
End If
End If
Next
Else
If inStr(currentSimilarBugIds, preSimilarBugIds) = False Then
getDeletedSimilarBugId = preSimilarBugIds
End If
End If
Set similarBugIdList = nothing
Set currentSimilarBugIds = nothing
Set preSimilarBugIds = nothing
Set objBugHistList = nothing
Set objBug = nothing
Set objBugFactory = nothing