Developer1
Visitor.
1450 views

Display fullname instead of showing user id

Jump to solution

Hi,

I am trying to display fullname in defects modules. I did searched on this forum and got some code to start working with by modifying Sub Bug_fieldchange(FieldName), Sub Bug_MoveTo, Sub Bug_New and created function called Function UserFullName(UserID) in work flow script.

I am using BG_USER_04 = DETECTED BY and BG_USER_13 = ASSIGNED TO (BG_RESPONSIBLE), both the bg_user_04 and bg_user_13 are created as user fields with string type. We are using LDAP for getting user ids

I have attached my code and we are using HP ALM version 12.53.

Can anyone look into this code and please let me know what I might be doing wrong here?

 

 

 

Sub Bug_New
WizardFieldCust_Add ' Added by wizard
Bug_Fields("BG_SUBJECT").IsReadOnly = False
Bug_Fields("BG_REPRODUCIBLE").IsReadOnly = True
Bug_Fields("BG_PLANNED_CLOSING_VER").IsReadOnly = True
Bug_Fields("BG_DETECTION_VERSION").IsReadOnly = True
Bug_Fields("BG_CLOSING_VERSION").IsReadOnly = True
Bug_Fields("BG_ACTUAL_FIX_TIME").IsReadOnly = True

'harry start

On Error Resume Next


'Display Full Name in Assigned to field
'BG_RESPONSIBLE = Assigned To:
'BG_USER_13 = Full name

Fields("BG_USER_13").IsVisible = true
Fields("BG_USER_13").IsReadOnly = true

'Display Full Name in Assigned to field
'BG_Detected_by = Assigned To:
'BG_USER_04 = Full name

Fields("BG_USER_04").IsVisible = true
Fields("BG_USER_04").IsReadOnly = true

On Error GoTo 0

'harry end

End Sub


Sub Bug_MoveTo
WizardFieldCust_Details ' Added by wizard
WizardListCust ' Added by wizard
Bug_Fields("BG_SUBJECT").IsReadOnly = True
Bug_Fields("BG_REPRODUCIBLE").IsReadOnly = True
Bug_Fields("BG_PLANNED_CLOSING_VER").IsReadOnly = True
Bug_Fields("BG_DETECTION_VERSION").IsReadOnly = True
Bug_Fields("BG_CLOSING_VERSION").IsReadOnly = True
Bug_Fields("BG_ACTUAL_FIX_TIME").IsReadOnly = True

'harry start
On Error Resume Next

Set Fields = Bug_Fields

Bug_Fields.Field("BG_USER_13").IsVisible = true
Bug_Fields.Field("BG_USER_13").IsReadOnly = false

Bug_Fields.Field("BG_USER_04").IsVisible = true
Bug_Fields.Field("BG_USER_04").IsReadOnly = false

'Display Full Name in Assigned to field
'BG_RESPONSIBLE = Assigned To:
'BG_USER_13 = Full name

Fields("BG_USER_13").IsVisible = true
Fields("BG_USER_13").IsReadOnly = false

if Fields("BG_USER_13").Value <> UserFullName(Fields("BG_RESPONSIBLE").Value) then

Fields("BG_USER_13").Value = UserFullName(Fields("BG_RESPONSIBLE").Value)
end if

Bug_Fields.Field("BG_USER_13").IsReadOnly = true

'Display Full Name in Detected By field
'BG_DETECTED_BY = Detected By:
'BG_USER_04 = Detected by Full name

Fields("BG_USER_04").IsVisible = true
Fields("BG_USER_04").IsReadOnly = false

if Fields("BG_USER_04").Value <> UserFullName(Fields("BG_DETECTED_BY").Value) then

Fields("BG_USER_04").Value = UserFullName(Fields("BG_DETECTED_BY").Value)
end if

Bug_Fields.Field("BG_USER_04").IsReadOnly = true

WizardFieldCust_Details ' Added by wizard
On Error GoTo 0

'harry end
End Sub


Sub Bug_FieldChange(FieldName)
WizardListCust ' Added by wizard

'harry start
On Error Resume Next

'Display Full Name in Assigned to field
'BG_RESPONSIBLE = Assigned To:
'BG_USER_13 = Full name

if FieldName = "BG_RESPONSIBLE" then

Fields("BG_USER_13").IsReadOnly = false
Fields("BG_USER_13").Value = UserFullName(Bug_Fields.Field("BG_RESPONSIBLE").Value)
Fields("BG_USER_13").IsReadOnly = true

End If

'Display Full Name in Detected by to field
'BG_DETECTED_BY = Detected by:
'BG_USER_04 = Detected by Full name

if FieldName = "BG_DETECTED_BY" then

Fields("BG_USER_04").IsReadOnly = false
Fields("BG_USER_04").Value = UserFullName(Bug_Fields.Field("BG_DETECTED_BY").Value)
Fields("BG_USER_04").IsReadOnly = true

End If

On Error GoTo 0

'harry end
End Sub

 

 

'New Function Added for Display Full Name in Assigned to and detected by field
Function UserFullName(UserID)

Dim td
Dim cust
Dim cust_users
Dim c_user
set td=TDConnection

Set cust = td.Customization
Set cust_users = cust.Users
Set c_user = cust_users.User(UserID)

UserFullName = c_user.FullName

End Function

Thank you for your help.

Tags (2)
0 Likes
1 Solution

Accepted Solutions
Highlighted
cmt8455 Absent Member.
Absent Member.

Re: Display fullname instead of showing user id

Jump to solution

Hi Developer1. I just use a few lines of code to populate a user defined field for Full Name. For example, for Detected by, it would be:

If Bug_Fields.Field("BG_DETECTED_BY").Value <> "" then
       Bug_Fields.Field("BG_USER_04").Value = TDConnection.Customization.Users.User(Bug_Fields.Field("BG_DETECTED_BY").Value).FullName
 Else
       Bug_Fields.Field("BG_USER_04").Value = ""
End If

I have this code in Bug_New & Bug_FieldChange.

4 Replies
Highlighted
cmt8455 Absent Member.
Absent Member.

Re: Display fullname instead of showing user id

Jump to solution

Hi Developer1. I just use a few lines of code to populate a user defined field for Full Name. For example, for Detected by, it would be:

If Bug_Fields.Field("BG_DETECTED_BY").Value <> "" then
       Bug_Fields.Field("BG_USER_04").Value = TDConnection.Customization.Users.User(Bug_Fields.Field("BG_DETECTED_BY").Value).FullName
 Else
       Bug_Fields.Field("BG_USER_04").Value = ""
End If

I have this code in Bug_New & Bug_FieldChange.

Developer1
Visitor.

Re: Display fullname instead of showing user id

Jump to solution

Thanks cmt8455,

so that means I dont need to create new function or anything else, just put the code provided by you in bug_new and bug_fieldchange.

Will this code take care of the changes on while a new defect is logged, when a old defect is modified and on the defect grid page?

0 Likes
cmt8455 Absent Member.
Absent Member.

Re: Display fullname instead of showing user id

Jump to solution

You're welcome Developer1. I'm glad that I could help. Yes, the code will be applied with new defects & when the Detected By field is modified in the defect grid.

0 Likes
New Member.. MAM01
New Member..

Re: Display fullname instead of showing user id

Jump to solution

Hello,

I am also tyring ot do somethign similar. I would likeot display Full Name in place of the user ID in the BG_RESPONSIBLE (Assigned To) field. I am new to scripting.  Could I apply this without using a User Defined Field? Not sure of how to insert Full Name instead of User ID. 

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.