New Ranks & Badges For The Community!
Notice something different? The ranks and associated badges have gone "Star Fleet". See what they all mean HERE
Highlighted
Absent Member.
Absent Member.
851 views

Defect workflow customisation

Jump to solution
Hello,
In the defects module of QC, I have added a new field "Assigned to(Name)" so that I get the full name of the person to whom the defect is assigned to.
For example: If the value of the field "Assigned to" is "DIS", the value of the field "Assigned to (name)" is "Divya Seekunta".
I have been able to do so by hard coding each user's name in the defect workflow such that if a user selects the assigned to, the name is filled in.
If Bug_Fields.Field("BG_RESPONSIBLE").Value = "akr" Then
Bug_Fields.Field("BG_USER_03").Value = "Akshay Ramluckhun"
elseif Bug_Fields.Field("BG_RESPONSIBLE").Value = "dis" Then
Bug_Fields.Field("BG_USER_03").Value = "Divya Seekunta"
elseif Bug_Fields.Field("BG_RESPONSIBLE").Value = "khg" Then
Bug_Fields.Field("BG_USER_03").Value = "Khaleel Gurib"

Yet, this solution is not very optimising since the number of users is increasing.
Can you please provide me a solution or the codes to be able to do this without writing bulky vbscript codes? Thanks
0 Likes
24 Replies
Highlighted
Absent Member.
Absent Member.
Hello, i have tried the code but it is not working at my end.
I am using QC 10.0.
0 Likes
Highlighted
Absent Member.
Absent Member.
Hi Divya,
Use this one.

In the common script use the below function

Function GetUserName(gunUserID)
Dim gunTD, gunCust, gunCustUsers, gunCUser
On Error Resume Next

If gunUserID = "" Then
GetUserName = ""
Else
' TD customization - users - user - FullName method
Set gunTD = TDConnection
Set gunCust = gunTD.Customization
Set gunCustUsers = gunCust.Users
Set gunCUser = gunCustUsers.User(gunUserID)
GetUserName = gunCUser.FullName
End If
' Tidy up
Set gunTD = Nothing
Set gunCust = Nothing
Set gunCustUsers = Nothing
Set gunCUser = Nothing
On Error GoTo 0

End Function




Then in the Defect module workflow -> Sub Bug_FieldChange put the below statement..

If FieldName = "ID Field" Then
SetCustFieldAppVal "Neme Field", "", "", "", "", "", GetUserName(Bug_Fields.Field("ID field").Value)
End If


Try this and let me know.
0 Likes
Highlighted
Absent Member.
Absent Member.
I have put the following code in the common script:
Function GetUserName(gunUserID)
Dim gunTD, gunCust, gunCustUsers, gunCUser
On Error Resume Next

If gunUserID = "BG_USER_03" Then
GetUserName = "BG_RESPONSIBLE"
Else
' TD customization - users - user - FullName method
Set gunTD = TDConnection
Set gunCust = gunTD.Customization
Set gunCustUsers = gunCust.Users
Set gunCUser = gunCustUsers.User(gunUserID)
GetUserName = gunCUser.FullName
End If
' Tidy up
Set gunTD = Nothing
Set gunCust = Nothing
Set gunCustUsers = Nothing
Set gunCUser = Nothing
On Error GoTo 0

End Function

And then in the Bug_Field Change function,
Sub Bug_FieldChange(FieldName)
On Error Resume Next
Fields= Bug_Fields
If FieldName = "BG_RESPONSIBLE" Then
SetCustFieldAppVal "BG_USER_03", "", "", "", "", "", GetUserName(Bug_Fields.Field("BG_RESPONSIBLE").Value)
End If
On Error GoTo 0
End Sub

I dnt understand where i'm going wrong
0 Likes
Highlighted
Absent Member.
Absent Member.
Sub Bug_FieldChange(FieldName)
On Error Resume Next

If FieldName = "BG_RESPONSIBLE" Then
SetCustFieldAppVal "BG_USER_03", "", "", "", "", "", GetUserName(Bug_Fields.Field("BG_RESPONSIBLE").Value)
End If

On Error GoTo 0
End Sub


use the above code. also make sure the name field is a string field and the SetCustFieldAppVal subroutine is in place.
It should work
0 Likes
Highlighted
Absent Member.
Absent Member.
also dont change anything in the getusername function. It will be a common function. Seems you have put the field name in the if condition.

put the one exactly which i sent earlier.
0 Likes
Highlighted
Absent Member.
Absent Member.
I have done exactly how you said but it is still not working. Please see attached screenshot.
The field "Assigned to(Name):" needs to be populated with the full name.
0 Likes
Highlighted
Absent Member.
Absent Member.
hi,
this piece of code will only work when you change the id field. it will not update the existing ones. Try to change any of the id field and see whether the name is getting changed.

0 Likes
Highlighted
Absent Member.
Absent Member.
yes, i've done that too.
On clicking new bug, when i select the value of the field Assigned to, i expect the field Assigned to name to be filled in but it is not the case
0 Likes
Highlighted
Absent Member.
Absent Member.
Hi Divya,

Can you attach the screenshot of the workflow screen with the defects part highlighted. Also, attach a screenshot of the user defined fields with the "Assigned To (Name)" field highlighted.

Thanks,
Shivaraj
0 Likes
Highlighted
Knowledge Partner Knowledge Partner
Knowledge Partner
For debuging purpose try add the
msgbox "Assigned Field: " & Bug_Fields.Field("BG_RESPONSIBLE").Value

or

msgbox "Assigned FullName: " & Bug_Fields.Field("BG_USER_03").Value

rows to whenever it is possible to see if the fields are populated.
0 Likes
Highlighted
Knowledge Partner Knowledge Partner
Knowledge Partner
Do not do it so complicated. If you will use it only here you do not need another function.

Just change the subroutine "Sub Bug_FieldChange(FieldName)" to this:
---------------------
Sub Bug_FieldChange(FieldName)
On Error Resume Next
if FieldName = "BG_RESPONSIBLE" then
fn = TDConnection.Customization.Users.User(Bug_Fields.Field("BG_RESPONSIBLE").Value).FullName
if Bug_Fields.Field("BG_RESPONSIBLE").Value = "" then fn = ""
Bug_Fields.Field("BG_USER_03").Value = fn
end if
On Error GoTo 0
End Sub
------------------------

But pay attention there must not be anywhere else something what can change the field value.

Or comment the line " On Error Resume Next" and " On Error GoTo 0" by adding apostrof so you will se if there are some syntax errors.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.
Hello, thanks a lot, the code is working.
I will try to do the same thing for detected by.
🙂
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.