Este enganche extrae nombres de inicio de sesión de usuario que son miembros de un grupo con acceso a esta base de datos y los carga en la lista de opciones para el campo.
Sub AssignedTo_ChoiceList(fieldname, choices) ' fieldname As String ' choices As Object ' entityDef = Defect Dim sessionObj Dim queryObj Dim filterObj Dim resultSetObj Set sessionObj = GetSession() ' start building a query of the users Set queryObj = sessionObj.BuildQuery("users") ' have the query return the desired field of the user object(s) queryObj.BuildField ("login_name") ' filter for members of group "MyGroup" (whatever group you want) Set filterObj = queryObj.BuildFilterOperator(AD_BOOL_OP_AND) filterObj.BuildFilter "groups", AD_COMP_OP_EQ, "MyGroup" Set resultSetObj = sessionObj.BuildResultSet(queryObj) ' run it resultSetObj.Execute ' add each value in the returned column to the choicelist Do While resultSetObj.MoveNext = AD_SUCCESS choices.AddItem resultSetObj.GetColumnValue(1) Loop End Sub
sub AssignedTo_ChoiceList { my($fieldname) = @_; my @choices; # $fieldname as string scalar # @choices as string array # record type name is Defect # field name is myuser # use array operation to add items. For example: # push(@choices, "red", "green", "blue"); my $session = $entity->GetSession(); # start building a query of the users my $queryDefObj = $session->BuildQuery("users"); # have the query return the desired field of the user object(s) $queryDefObj->BuildField("login_name"); # filter for members of group "MyGroup" (whatever group you want) my $filterOp = $queryDefObj->BuildFilterOperator( $CQPerlExt::CQ_BOOL_OP_AND); my @array = ("MyGroup"); $filterOp->BuildFilter("groups", $CQPerlExt::CQ_COMP_OP_EQ, \@array); my $resultSetObj = $session->BuildResultSet($queryDefObj); # run it $resultSetObj->Execute(); # add each value in the returned column to the choicelist while ($resultSetObj->MoveNext() == $CQPerlExt::CQ_SUCCESS) { push(@choices,$resultSetObj->GetColumnValue(1)); } return @choices; }