Scrip to remove requestors based on group membership

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;

Hi,
have a look onto your code:

  1. Condition:

==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;

I think, if you use the default condition (OnCreate) and do the rest inside
a userdefined action, this will work.

Torsten2009/11/20 darthmarth37 darthmarth@gmail.com

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;


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

MFG

Torsten Brumm

http://www.brumm.me