Should not be able to fail run step without having/linking atleast one defect

Posted: March 5, 2019 in Uncategorized

Function Step_FieldCanChange(FieldName, NewValue)
On Error Resume Next

if FieldName= "ST_STATUS" then
if Step_Fields("ST_ACTUAL").Value = "" then
Msgbox "Actual Result cannot be empty"
Step_FieldCanChange = False
Exit Function
else
Step_FieldCanChange = DefaultRes
end if

'If the new value is going to be Failed or Blocked...
If NewValue = "Failed" or NewValue = "Blocked" Then

'Get the Step ID of the current Step.
StepID = Step_Fields.Field("ST_ID").Value

'Get the Step factory from the StepID
Set StepFact = TDConnection.StepFactory

'Get the Step object from the Step Factory
Set StepObj = StepFactory.Item(StepID)

'Get the BugLinkFactory from the Step
Set BugLinkFact = StepObj.BugLinkFactory

'Set a blank filter to find all the current defects in the BugLinkFactory
Set BugLinkFactFilter = BugLinkFact.Filter

'Apply the filter and add the filtered items to a list
Set BugLinkFactList = BugLinkFactFilter.NewList

'Check the list to see if it is empty
If BugLinkFactList.Count = 0 Then
'Inform the user.
MsgBox "You must link a defect."
'Block the status change
Step_FieldCanChange = False
'leave
Exit Function
else
Step_FieldCanChange = DefaultRes
End If

'Kill the objects
Set BugLinkFactList = Nothing
Set BugLinkFactFilter = Nothing
Set BugLinkFact = Nothing
Set StepObj = Nothing
Set StepFact = Nothing

End If
end if
On Error GoTo 0
End Function

Leave a comment