[rt-users] Scrip to remove requestors based on group membership

darthmarth37 darthmarth at gmail.com
Fri Nov 20 12:34:06 EST 2009


I'm trying to write a scrip that removes the requestor of a new ticket
if the requestor's email address is in a specific "no-reply" group in
RT (for things like Nagios messages that don't need replies), and I
think I'm getting confused when trying to make it work.  What I have
so far (below) doesn't have any effect on new tickets.  Any ideas what
I'm messing up?

==Condition==
my @exceptionGroups = ('no-reply');

my $principalobj = RT::Principal->new($RT::SystemUser);
$principalobj->Load($self->TransactionObj->CreatorObj->Id);

my $transactionType = $self->TransactionObj->Type;
if ($transactionType eq 'Create') {
    foreach (@exceptionGroups) {
        my $groupobj = RT::Group->new($RT::SystemUser);
        $groupobj->LoadUserDefinedGroup($_);
        if ($groupobj->HasMemberRecursively($principalobj)) {
            return 1;
        }
    }
}
return 0;

==Action==
my $principalobj = RT::Principal->new($RT::SystemUser);
$principalobj->Load($self->TransactionObj->CreatorObj->Id);

my ($status, $msg) = $self->TicketObj->DeleteWatcher(Type =>
"Requestor", PrincipalId => $principalobj);
return $status;



More information about the rt-users mailing list