Function Defects_Bug_CanPost
On Error Resume Next
if Bug_Fields.Field("BG_STATUS").Value = "新建" and UserGroup(Bug_Fields("BG_RESPONSIBLE").Value) <> "研发工程师" then
msgbox "请把新建的BUG单交给研发部门成员"
Defects_Bug_CanPost = False
End if
On Error GoTo 0
End Function
Function UserGroup (tuser)
Dim Cust
Dim CustUserGroups
Dim CustGroup
Set td = TDConnection
Set Cust = td.Customization
Cust.Load
Set CustUserGroups = Cust.UsersGroups
Set CustGroupList = CustUserGroups.Groups
usergroup = ""
For i = 1 To CustGroupList.Count
Set CustGroup = CustUserGroups.Group(CustGroupList(i).Name)
Set GroupUserList = CustGroup.UsersList
For j = 1 To GroupUserList.Count
If GroupUserList(j).Name = tuser Then
usergroup = CustGroupList(i).Name
Exit For
End If
Next
If usergroup <> "" Then
Exit For
End if
Next
Set CustUserGroups = nothing
Set CustGroupList = nothing
Set CustGroup = nothing
Set GroupUserList = nothing
Set td = nothing
End Function