Use of HasGroupRight method

Hi all,
how can i use the method HasGroupRight in a User Defined condition for a scrip?
I would like the condition return 1 only if the user that makes the transaction (exactly a Correspond) is part of the “Operators” group

Thanks

You can load the group and check if the user creating a transaction is in the group:

my $group = RT::Group->new( RT->SystemUser );
my($ret, $msg) = $group->LoadUserDefinedGroup( Name => "Operators" );
unless ($ret) {
    RT::Logger->error("Could not load Operators group: $msg");
    return 0;
}

return $group->HasMemberRecursively( $self->TransactionObj->Creator );

it doesn’t work i also tried with

my $TransactionObj = $self->TransactionObj;
my $user = $self->TransactionObj->CreatorObj;
my $test = $user -> HasGroupRight (Name => "Operators");
RT::Logger->error("HASRIGHT name: $name -- test: $test");

but it still doesn’t work

Use of uninitialized value $test in concatenation

I think you might want to check what you need to pass as parameters to HasGroupRight. You need to give either GroupObj pointing at an RT::Group object or Group with the ID of a group, and then a Right parameter with the name of the right you want to check that they have. You’ve not defined $name either.

I think as @knation assumed your looking to see if someone is a member of a group (possibly recursively) rather than they have a particular right on that group? Those are different, so make sure that you know which you’re trying to achieve!

thank you very much, I was really wrong then … thanks to all.
I just edited
$group->LoadUserDefinedGroup( Name => "Operators" );
in
$group->LoadUserDefinedGroup( "Operators" );
and it works, thanks to @GreenJimll e @knation
I used this User Defined condition

my $mygroup = "Operators";
my $creatorname = $self->TransactionObj->CreatorObj->Name;
my $group = RT::Group->new( RT->SystemUser );
my($ret, $msg) = $group->LoadUserDefinedGroup( "$mygroup" );
unless ($ret) {
    RT::Logger->error("Non è stato possibile trovare il gruppo $mygroup: $msg");
    return 0;
}
my($ret2, $msg2) = $group->HasMemberRecursively( $self->TransactionObj->Creator );
unless ($ret2) {
    RT::Logger->error("$creatorname non è membro del gruppo $mygroup: $msg2");
    return 0;
}
return 1;