Ok, so worked it out myself eventually........
This goes in the Common Script
'############################################################################### 'Functionality : Checks if UserName is member of a group given in Groupname. 'Parameter(s) : Username and Groupname both as string. 'Returns : a boolean value indicating membership. '############################################################################### Function isInGroup(userName, groupName) Set tdc = TDConnection Set cust = tdc.Customization Set users = cust.Users Set usr = users.user(userName) isInGroup = usr.InGroup(Cstr(groupName)) Set usr = Nothing Set users = Nothing Set cust = Nothing Set tdc = Nothing End Function
This goes into the Defects Module Script
Function ChangePrimaryAssignGroup(FieldName) Set tdc = TDConnection Set com = tdc.Command UserID = Bug_Fields("BG_RESPONSIBLE").value com.CommandText="SELECT GR_GROUP_NAME FROM USERS,GROUPS WHERE SUBSTR(US_GROUP, GR_GROUP_ID + 1, 1) = 1 and US_USERNAME = '"&UserID&"'" Set recsetTest=com.Execute sResult = recsetTest(GR_GROUP_NAME) Set com = nothing Set recsetTest = nothing IF isInGroup(Bug_Fields("BG_RESPONSIBLE").Value, sResult) Then Bug_Fields("BG_USER_01").Value = sResult Else Bug_Fields("BG_USER_01").Value = "No Group" End If End Function
And this goes into Bug_FieldChange(FieldName) and into Bug_MoveTo
If ChangePrimaryAssignGroup(Bug_Fields.Field("BG_Responsible")) Then Bug_Fields("BG_USER_01").Value = sResult End If
Hope this helps someone else
Cheers