Scrip send email on create

Enclosed is a script that adds one or more AdminCC’s to a ticket during
Create. This does not cause the AdminCC’s to receive an email.

How do I modify this Scrip or otherwise configure the Queue such that
AdminCC’s will receive a copy of the text in the opening transaction?

Here is the scrip information. I’ve reviewed the contributions page and
read what I can before asking this question. Thanks for the help.

Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: Transaction Create

Custom condition:
Custom action preparation code: return 1;
Custom action cleanup code:

my $owner_id = $self->TicketObj->Owner;
my $requestor_email = $self->TicketObj->RequestorAddresses;
my $admincclist = $self->TicketObj->AdminCc;
my @actors = (‘fred@company.com’, ‘wilma@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 undef;
}
}
}
} else {
return 0;
}

Dan,

I didn't see a template listed. listed. I don't think an Email can be 

sent without one.

Kenn
LBNLOn 2/2/2009 4:05 PM, Dan O’Neill wrote:

Enclosed is a script that adds one or more AdminCC’s to a ticket during
Create. This does not cause the AdminCC’s to receive an email.

How do I modify this Scrip or otherwise configure the Queue such that
AdminCC’s will receive a copy of the text in the opening transaction?

Here is the scrip information. I’ve reviewed the contributions page and
read what I can before asking this question. Thanks for the help.

Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: Transaction Create

Custom condition:
Custom action preparation code: return 1;
Custom action cleanup code:

my $owner_id = $self->TicketObj->Owner;
my $requestor_email = $self->TicketObj->RequestorAddresses;
my $admincclist = $self->TicketObj->AdminCc;
my @actors = (‘fred@company.com’, ‘wilma@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 undef;
}
}
}
} else {
return 0;
}


The rt-users Archives

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

Dan O’Neill wrote:

Enclosed is a script that adds one or more AdminCC’s to a ticket during
Create. This does not cause the AdminCC’s to receive an email.

How do I modify this Scrip or otherwise configure the Queue such that
AdminCC’s will receive a copy of the text in the opening transaction?

Here is the scrip information. I’ve reviewed the contributions page and
read what I can before asking this question. Thanks for the help.

Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: Transaction Create

A little update. At the suggestion of some docs on the wiki, I added a
new template to see if that would get this scrip to send a notification
to the AdminCC’s. Didn’t work, still no outbound notification. I’ll
whip up an Amazon gift certificate to anyone who can help me resolve
this problem before close of business Wednesday.

Thanks,

Dan

possibly:

Stage: TransactionBatch

From memory (at least in RT-3.6.x) I think you also have to enable
batch transactions in RTSiteConfig.pm, something like:

Set($UseTransactionBatch , 1);

Gordon

Dan O’Neill 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

Scrip #1:

Description: On Create Notify AdminCcs
Condition: On Create
Action: Notify AdminCcs
Template: Global template: Transaction
Stage: Transaction Create

Custom condition:
Custom action preparation code:
Custom action cleanup code:

Scrip #2:

Description: 1 Add AdminCC
Condition: On Create
Action: User Defined
Template: Global Template: Blank
Stage: TransactionCreate

Custom condition:
Custom action preparation code: return 1;
Custom action cleanup code:

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 undef;
}
}
}
} else {
return 0;
}

Hope this helps.From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Dan O’Neill
Sent: Tuesday, February 03, 2009 4:52 PM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Scrip send email on create

Dan O’Neill wrote:

Enclosed is a script that adds one or more AdminCC’s to a ticket during
Create. This does not cause the AdminCC’s to receive an email.

How do I modify this Scrip or otherwise configure the Queue such that
AdminCC’s will receive a copy of the text in the opening transaction?

Here is the scrip information. I’ve reviewed the contributions page and
read what I can before asking this question. Thanks for the help.

Condition: On Create
Action: User Defined
Template: Global template: Blank
Stage: Transaction Create

A little update. At the suggestion of some docs on the wiki, I added a
new template to see if that would get this scrip to send a notification
to the AdminCC’s. Didn’t work, still no outbound notification. I’ll
whip up an Amazon gift certificate to anyone who can help me resolve
this problem before close of business Wednesday.

Thanks,

Dan
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

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
TransactionBatchStage - Request Tracker Wiki covers my
problem well.

Does anyone have a solution for rt 3.4.5?

Dan

Dan,

I may be wrong, but I believe you can order the sequence of scrips by 

the name field. I put a 1a, 1b, 2a, 2c in front of the name of several
scrips I have that run for the same transaction, but need them to run in
sequence. That and setting the TransactionBatch to 1 works for me. Hope
this helps. Hope this helps.

Kenn
LBNLOn 2/4/2009 10:34 AM, Dan O’Neill wrote:

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
TransactionBatchStage - Request Tracker Wiki covers my
problem well.

Does anyone have a solution for rt 3.4.5?

Dan


The rt-users Archives

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