Limit Test Plan field change
First create a new user field in Test under Project Entities in Project Customization. This is the field that we will use to hold the user that last changed the field to “Design” once that user has changed the value to Design they should not be able to change the status again. In a sense what we are doing is locking the test when it is changed to “Design” so that the user that last made the change might not try to circumvent the rules by changing the status to something else and then try and jump straight to “Ready”
I created a field to hold the value of the user that last changed the test to Design so that we can see who changed the status to “Design”, in the workflow I made the field read only so that a user might not try to change the field to “circumvent the rules” of the code and change the value of the Status field. In my environment this field name was ”TS_USER_01” you will need to replace this value in the code with the name of the field that you use to hold the user name.
In the select case you will need to change the values to match what you have for your “Plan Status” project list, they currently have entries for my “Plan Status” project list. You should not need to include “Design” since it does not matter if the field is changed from “Design” back to “Design” just so that it is not changed to any other status.
Note: This is just an example, use code at your own risk, you will need to change this code to apply to your environment
In the workflow code (place the code pieces into the same subs that I did):
- Sub Test_MoveTo
- On Error Resume Next
- Test_Fields.field("TS_USER_01").IsReadOnly=true
- On Error GoTo 0
- End Sub
- Sub Test_FieldChange(FieldName)
- On Error Resume Next
- 'This sets the user name field to the user name that changes the status to "Design"
- If Test_Fields.field("TS_STATUS").IsModified=true then
- if Test_Fields.field("TS_STATUS").Value = "Design" then
- Test_Fields.field("TS_USER_01").IsReadOnly=false
- Test_Fields.field("TS_USER_01").Value = User.UserName
- Test_Fields.field("TS_USER_01").IsReadOnly=true
- end if
- End If
- On Error GoTo 0
- End Sub
- Function Test_FieldCanChange(FieldName, NewValue)
- On Error Resume Next
- 'This select case ensures that the user that last changed the status to "Design" can no longer
- 'change the status of the test. Each case other than "Design" needs an option so that the user
- 'cannot change the status once they have changed it to "Design"
- Test_FieldCanChange = DefaultRes
- Select Case NewValue
- Case "Ready"
- If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
- msgbox "Current user has already changed the status to Design and cannot change current status"
- Test_FieldCanChange=FALSE
- End If
- Case "Imported"
- If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
- msgbox "Current user has already changed the status to Design and cannot change current status"
- Test_FieldCanChange=FALSE
- End If
- Case "Repair"
- If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
- msgbox "Current user has already changed the status to Design and cannot change current status"
- Test_FieldCanChange=FALSE
- End If
- End Select
- On Error GoTo 0
- End Function
0 comments:
Post a Comment