[Rt-devel] Re: UserDefined scrip action

Ruslan U. Zakirov Ruslan.Zakirov at acronis.com
Thu Dec 9 11:42:32 EST 2004


Jan Okrouhly wrote:
> Hello,
> 
> we use RT 3.2.2 and meet big troubles with custom action scrips - it works
> only sometimes (maybe just only once). This example for is i.e. not
> working well if used in Scrip for specific Queue.
> Is this approach wrong/where is the problem?
> I (customer) doesn't want to use additional files like yours good one
> Action/NotifyGroup.pm, because the LoadedGroup will change depending on
> some ticket info (Customer CustomFields)...
Start from http://wiki.bestpractical.com/?Debug
Comments about code below.

> 
> Prepare part:
> ----- cut here -----
> package RT::Action::tmp;
> use strict;
> use vars qw/@ISA/;
> require RT::Action::Notify;
> @ISA = qw(RT::Action::Notify);
> sub SetRecipients {
>     my $self = shift;
> 
>     my ($group);
>     my @Bcc;
> 
>     $group = new RT::Group($RT::SystemUser);
>     $group->LoadUserDefinedGroup("RT AdminCc");
> 
>     unless ($group->Id ) {
>         $RT::Logger->warning("Searching Group Global AdminCc failed, can't set recipients!\n");
> 
>         return;
>     }
> 
>     my $members = $group->UserMembersObj();
>     while (my $member = $members->Next()) {
> 
>         my $user = $member->EmailAddress;
>         if ($user && ! ( grep (/^$user$/, @Bcc) ) ) {
          if ($user && ! ( grep (/^\Q$user\E$/, @Bcc) ) ) {

>                 push ( @Bcc, $user );
>         }
>     }
> 
>     if ($RT::UseFriendlyToLine) {
>             push (
>                 @{$self->{'PseudoTo'}},
>                 sprintf($RT::FriendlyToLineFormat, "GroupNotify", $self->TicketObj->id),
>             );
>     }
> 
>     if ($RT::NotifyActor) {
unless($RT::NotifyActor) {

>         # Do not send notification to the crator of the transaction
>         my $creator;
>         $creator = $self->TransactionObj->CreatorObj->EmailAddress() if ($self->TransactionObj);
>         # override possible 'Bcc'
> 
>         @{$self->{'Bcc'}} = grep (!/^$creator$/, @Bcc);
          @{$self->{'Bcc'}} = grep (!/^\Q$creator\E$/, @Bcc);

>     } else {
>         @{$self->{'Bcc'}} = @Bcc;    }
> 
>     $RT::Logger->warning("GroupNotify Bcc is:".join(',',@{$self->{'Bcc'}})."\n");
> 
>     return (1)
> }
> 
> 1;
> 
> my $tmpscrip;
> $tmpscrip = new RT::Action::tmp(
> TransactionObj => $self->{'TransactionObj'},
> TemplateObj => $self->{'TemplateObj'},
> TicketObj => $self->{'TicketObj'},
> ScripObj => $self->{'ScripObj'},
> Type => $self->{'Type'},
> CurrentUser => $self->CurrentUser,
> );
> 
> $self->{'tmpscrip'} = $tmpscrip;
> 
> my $res=$tmpscrip->Prepare();
> #use Data::Dumper;
> #$RT::Logger->warning(Dumper($self->TemplateObj->MIMEObj->head));
> return $res;
> ----- cut here -----
> Commit part is only:
> ----- cut here -----
> $self->{'tmpscrip'}->Commit;
> ----- cut here -----
> 
> 
> Jan Okrouhlý
> 
> //------------------------------------\-\-\+\-\-\---okrouhly at civ.zcu.cz-\\
> |Laboratory for Computer Science           |    phone: +420 377 632 837  |
> |University of West Bohemia                | location: Univerzitni 22    |
> |Americka 42, 306 14 Pilsen, Czech Republic|     room: UI402             |
> +---------------------------------------73-!-de-OK1INC at OK0PPL.#BOH.CZE.EU+
> |  Monday or Tuesday:                      |    phone: +420 224 355 263  |
>  \\___________________CESNET z.s.p.o.______|_location: Zikova 4, Prague_//
> 



More information about the Rt-devel mailing list