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

Torsten Brumm torsten.brumm at googlemail.com
Mon Nov 23 14:31:47 EST 2009


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.

Torsten


2009/11/20 darthmarth37 <darthmarth at 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 at 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
http://www.elektrofeld.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20091123/f8c9e559/attachment.htm>


More information about the rt-users mailing list