Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Request Tracker: Users

Scrip to remove requestors based on group membership

 

 

Request Tracker users RSS feed   Index | Next | Previous | View Threaded


darthmarth at gmail

Nov 20, 2009, 9:34 AM

Post #1 of 2 (584 views)
Permalink
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;
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales [at] bestpractical


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


torsten.brumm at googlemail

Nov 23, 2009, 11:31 AM

Post #2 of 2 (541 views)
Permalink
Re: Scrip to remove requestors based on group membership [In reply to]

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>

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

Request Tracker users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.