确保该实体属性在聚焦于实体之前设置
创建或修改新实体(New 或 FieldChanged)时设置实体属性(如 IsVisible、IsRequired 和 List)是常规的做法。编写 ALM 工作流脚本时,设置聚焦于实体(即用户在 ALM 图形用户界面中导航到该实体)时的实体属性也很重要。聚焦于实体时调用 MoveTo 事件。
如果未在 MoveTo 事件中设置实体值,则最终的用户体验将不可预知 - 例如,可能在下拉列表中显示不正确的值。
建议
为避免不可预知的结果,如未包含最新值集合的下拉列表:
-
确保在 MoveTo 事件中设置了所有实体的属性 - 不只是在 New 或 FieldChanged 事件中。
-
将实体属性自定义代码隔绝到单独的例程中,并从所有相关事件调用该例程。
下表提供的示例演示了如何在聚焦于缺陷 (不只是修改或添加它) 时确保缺陷的属性正确设置。
示例:
Sub SetupBugFields(Context1, Context2)
' Code for customizing defect properties is entered here,
' such as set IsVisible, IsRequired, IsReadonly, Label, List...
If Context1="Focus" Then
' Code for handling the focus event is entered here
ElseIf Context1="FieldChange" Then
If Context2="RQ_USER_01" Then
' Code for handling the FieldChange event
' is entered here
ElseIf Context2="RQ_REQ_STATUS" Then
' ...Enter your code here
Else
' ...Enter your code here
End If
End If
End Sub
Sub Req_FieldChange(FieldName)
If FieldName = "RQ_REQ_STATUS" Then
SetupBugFields("FieldChange", FieldName)
Else
' ...Enter your code here
End If
End Sub
Sub Req_MoveTo
SetupBugFields("Focus")
End Sub

