Autopopulate a custom field with the UserID of the user logged in when changes are made

  • Questions
  • Autopopulate a custom field with the UserID of the user logged in when changes are made
Question ID: 107290
0
0

I have a custom field titled ‘Assigned Test Automater’ that I am interested in defaulting to a specific value depending on who is logged in to Quality Center. I’d like to, when a new test case is created in QC, have the assigned automater field default to the person logged in to Quality Center. In addition, I’d like, when the user converts a manual test to a UFT test, that this field also default to the person logged in to Quality Center. The tests will be created in ALM, and the users will be converting the manual test to quicktest using the Generate Script button. Is there a way to do this? Thanks!

Marked as spam
Posted by (Questions: 219, Answers: 23)
Asked on December 2, 2016 8:33 pm
12 views
Answers (1)
0
Private answer

Since the 'TS_Responsible' field auto-populates with the user logged in, I used that field to populate the custom field. Enter the script below into the 'Sub Test_FieldChange' and 'Sub Test_New' functions within the 'Test Plan module script'. The Sub Test_New script will auto-populate the custom field with the userid of the user logged in when the test is created. The Sub Test_FieldChange script will populate the custom field with the userid if it is changed in the 'Designer' field.

Sub Test_New
'On Error Resume Next
Test_Fields.Field(''TS_USER_01'').IsReadOnly = True 'True for Read-only or False to enable editing.
Test_Fields.Field(''TS_USER_01'').IsVisible = True 'True to display the field or False to hide the field.
Test_Fields.Field(''TS_RESPONSIBLE'').IsVisible = False 'True to display the field or False to hide the field.
Test_Fields.Field(''TS_USER_01'').Value = User.UserName 'Auto-populates the field during test creation.
'On Error GoTo 0
End Sub

Sub Test_FieldChange(FieldName)
'On Error Resume Next
If FieldName = Test_Fields(''TS_RESPONSIBLE'').FieldName Then
Test_Fields(''TS_USER_01'').Value = Test_Fields(''TS_RESPONSIBLE'').Value
End If
'On Error GoTo 0
End Sub

The following script will auto-populate the custom field with the userid of the user logged in when the test type is changed from 'MANUAL' to 'QUICKTEST_TEST' using the Script Generator. Place the script below into the 'ActionCanExecute' function within the 'Common script' in the Script Editor.

If (ActionName = ''TestDesignStepsGenerate.QUICKTEST_TEST'') Then
Test_Fields.Field(''TS_USER_01'').Value = User.UserName
End If

Marked as spam
Posted by (Questions: 2, Answers: 280)
Answered on December 2, 2016 8:35 pm