[rt-users] Scrip send email on create - SOLVED
Dan O'Neill
rt at northpb.com
Wed Feb 4 17:08:32 EST 2009
The solution provided by Jeremy Burke was effective for RT 3.4.5.
Thanks Jeremy!
dan
Jeremy Burke wrote:
> Hi Dan,
>
> I should preface this by saying I'm pretty new at Perl and the whole RT thing, so I'm trying to learn as I go which is why I'm interested in your issue.
>
> You could try to do this using a Custom Condition that checks to see if it is during create and if it is, add the AdminCCs there. Then use the Notify AdminCCs Action. If you always want to notify AdminCCs on create, you just need to make sure the Condition always returns true whether or not an AdminCC is added by your scrip.
>
> Something like this maybe?
>
> Description: Add AdminCC and always email AdminCC
> Condition: User Defined
> Action: Notify AdminCCs
> Template: Global template: Transaction
> Custom Condition:
>
> # Return 0 and exit if not Create
> if ($self->TransactionObj->Type ne "Create") { return 0; }
> # Add AdminCC if subject match and always e-mail AdminCC
> my $owner_id = $self->TicketObj->Owner;
> my $requestor_email = $self->TicketObj->RequestorAddresses;
> my $admincclist = $self->TicketObj->AdminCc;
> my @actors = ('fred at company.com', 'wilma at company.com');
> my $user = RT::User->new($RT::SystemUser);
>
> if ( $self->TicketObj->Subject =~ m/Customer A/i ) {
> foreach my $actor (@actors) {
> $user->LoadByEmail($actor);
> my $user_id = $user->Id;
> my $user_email = $user->EmailAddress;
> if ( $user_email ne $requestor_email )
> {
> my($status, $msg) = $admincclist->AddMember($user->Id);
> unless( $status ) {
> $RT::Logger->warning( "can't add ticket owner as Cc : msg" );
> return 1;
> }
> }
> }
> }
>
> 1;
>
> Custom action preparation code: <empty>
> Custom action cleanup code: <empty>
>
> Good Luck,
>
> Jeremy
>
> -----Original Message-----
> From: Dan O'Neill [mailto:rt at northpb.com]
> Sent: Wednesday, February 04, 2009 10:35 AM
> To: Jeremy Burke
> Cc: rt-users at lists.bestpractical.com
> Subject: Re: [rt-users] Scrip send email on create
>
> Jeremy Burke wrote:
>> I think you need 2 scrips. The scrip you have below and then another scrip to send e-mail on create to the AdminCCs. You need to make sure the Add AdminCC scrip you have below is executed before the scrip that sends to the AdminCCs.
>>
>> I'm using RT 3.8.1 and this is how I have it setup to work. The 1 at the beginning of Scrip #2's description forces this scrip to be run before scrip #1
>
> Jeremy,
>
> Thanks for the information. This helps, but doesn't solve the problem
> because I'm using RT 3.4.5 which does not guarantee scrip order. Thus,
> an upgrade is likely to be the path I have to take. I really don't want
> to upgrade right now.
>
> This wiki article
> http://wiki.bestpractical.com/view/TransactionBatchStage covers my
> problem well.
>
> Does anyone have a solution for rt 3.4.5?
>
> Dan
More information about the rt-users
mailing list