Automation Testing, Manual Testing, QTP/UFT 11 , QC/ALM 11 ,SAP TAO, Unix, Selenium, Oracle SQL, Shell Scripting and For Online Trinings to contact me : Cell:+91-8897972059 , Email Id : quicktestprotech@gmail.com

Wednesday, August 13, 2014

Limit Test Plan field change


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):
  1. Sub Test_MoveTo
  2. On Error Resume Next
  3. Test_Fields.field("TS_USER_01").IsReadOnly=true
  4. On Error GoTo 0
  5. End Sub
  6.  
  7. Sub Test_FieldChange(FieldName)
  8. On Error Resume Next
  9. 'This sets the user name field to the user name that changes the status to "Design"
  10. If Test_Fields.field("TS_STATUS").IsModified=true then
  11. if Test_Fields.field("TS_STATUS").Value = "Design" then
  12. Test_Fields.field("TS_USER_01").IsReadOnly=false
  13. Test_Fields.field("TS_USER_01").Value = User.UserName
  14. Test_Fields.field("TS_USER_01").IsReadOnly=true
  15. end if
  16. End If
  17.  
  18.  
  19. On Error GoTo 0
  20. End Sub
  21.  
  22.  
  23. Function Test_FieldCanChange(FieldName, NewValue)
  24. On Error Resume Next
  25.  
  26. 'This select case ensures that the user that last changed the status to "Design" can no longer
  27. 'change the status of the test. Each case other than "Design" needs an option so that the user
  28. 'cannot change the status once they have changed it to "Design"
  29. Test_FieldCanChange = DefaultRes
  30. Select Case NewValue
  31. Case "Ready"
  32. If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
  33. msgbox "Current user has already changed the status to Design and cannot change current status"
  34. Test_FieldCanChange=FALSE
  35. End If
  36. Case "Imported"
  37. If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
  38. msgbox "Current user has already changed the status to Design and cannot change current status"
  39. Test_FieldCanChange=FALSE
  40. End If
  41. Case "Repair"
  42. If FieldName="TS_STATUS" and Test_Fields.field("TS_USER_01").value = user.UserName then
  43. msgbox "Current user has already changed the status to Design and cannot change current status"
  44. Test_FieldCanChange=FALSE
  45. End If
  46. End Select
  47.  
  48.  
  49. On Error GoTo 0
  50. End Function

0 comments:

Post a Comment

Loading...