Automatic CC owner on take

We currently use RT for our sales and technical support queries. Our
sales department really doesn’t like having to go through the browser
to do their correspondence, they would prefer just using email. So
I’ve cooked up a quick an dirty method that should work, if only I
could figure it out.

What I would like to happen is that when someone takes a ticket, it
adds them to the CC list and emails them the initial message. This
way all they have to use their browser for is take the ticket. I’ve
been going through the mailing list, and the wiki, cobbling together
something that I thought should work, but alas, it only partially
works. I’m hoping that someone can tell me what I’m doing wrong, and
at least give me a direction to go. For all I know, I’m
overcomplicating things, and there is a MUCH simpler means to
accomplish this.

My scrip so far is:

Condition: User Defined:

my $trans = $self->TransactionObj;
return 0 unless $trans->Field eq ‘Owner’;
return 1 if $trans->OldValue == RT::Nobody( )->id( );
return 0;

Action: User Defined:

Custom action preparation code:
my $new_id = $self->TransactionObj->NewValue;
my $new_user = RT::User->new();
$new_user->Load($new_id);
my $new_email = $new_user->EmailAddress();
$self->TicketObj->AddWatcher( Type => “Cc”,
Email => $new_email);
return 1;

Custom action cleanup code:
return 1;

Template:

{$Ticket->Transactions->First->Content()}

As I’ve said, this only partially works. The new owner does in fact
get added as a CC, however no email is sent. I check the logs and a
few things jump out:

The scip itself generates this warning:

Feb 15 12:08:26 rt RT: at //var/www/rt/rt-3.6.3/lib/RT/Base.pm line 92
Feb 15 12:08:26 rt RT::Base::CurrentUser(‘RT::User=HASH
(0xf69eb14)’) called at //var/www/rt/rt-3.6.3/lib/RT/Record.pm line 90
Feb 15 12:08:26 rt RT::Record::_Init(‘RT::User=HASH(0xf69eb14)’)
called at //var/www/rt/rt-3.6.3/lib/RT/User.pm line 79
Feb 15 12:08:26 rt RT::User::_Init(‘RT::User=HASH(0xf69eb14)’)
called at /usr/lib/perl5/vendor_perl/5.8.8/DBIx/SearchBuilder/
Record.pm line 362
Feb 15 12:08:26 rt DBIx::SearchBuilder::Record::new(‘RT::User’)
called at (eval 749) line 2
Feb 15 12:08:26 rt eval ’ my $last_id = $self->TransactionObj-

NewValue;
Feb 15 12:08:26 rt my $temp_user = RT::User->new();
Feb 15 12:08:26 rt $temp_user->Load($last_id);
Feb 15 12:08:26 rt my $last_email = $temp_user->EmailAddress();
Feb 15 12:08:26 rt $self->TicketObj->AddWatcher( Type => “Cc”,
Feb 15 12:08:26 rt Email => $last_email);
Feb 15 12:08:26 rt push( @{$self->{'To'}},
Feb 15 12:08:26 rt $self->TicketObj->QueueObj->Cc-
MemberEmailAddresses );
Feb 15 12:08:26 rt return 1;’ called at //var/www/rt/rt-3.6.3/lib/RT/
Action/UserDefined.pm line 63
Feb 15 12:08:26 rt RT::Action::UserDefined::Prepare
(‘RT::Action::UserDefined=HASH(0xf66cec8)’) called at //var/www/rt/
rt-3.6.3/lib/RT/ScripAction_Overlay.pm line 232
Feb 15 12:08:26 rt RT::ScripAction::Prepare(‘RT::ScripAction=HASH
(0xf692ad0)’) called at //var/www/rt/rt-3.6.3/lib/RT/Scrip_Overlay.pm
line 476
Feb 15 12:08:26 rt eval {…} called at //var/www/rt/rt-3.6.3/
lib/RT/Scrip_Overlay.pm line 470
<<>>>
Feb 15 12:08:26 rt RT: RT::User=HASH(0xf69eb14) was created without a
CurrentUser 1 (//var/www/rt/rt-3.6.3/lib/RT/Base.pm:92)

And finishes up with

Feb 15 12:08:26 rt RT: About to think about scrips for transaction
#458213
Feb 15 12:08:26 rt RT: About to prepare scrips for transaction #458213
Feb 15 12:08:26 rt RT: Found 2 scrips
Feb 15 12:08:26 rt RT: About to commit scrips for transaction #458213
Feb 15 12:08:26 rt RT: About to commit scrips for transaction #458212
Feb 15 12:08:26 rt RT:
rt-3.6.3-3363-1171566506-1830.41458-2-0@matrixorbital.ca
#41458/458212 - Scrip 2 (//var/www/rt/rt-3.6.3/lib/RT/Action/
SendEmail.pm:243)
Feb 15 12:08:26 rt RT:
rt-3.6.3-3363-1171566506-1830.41458-2-0@matrixorbital.ca No
recipients found. Not sending. (//var/www/rt/rt-3.6.3/lib/RT/Action/
SendEmail.pm:255)

Any help at all would be greatly appreciated.

-James

Well, after actually looking at what I wrote, I simplified the action
dramatically:

$self->TicketObj->AddWatcher( Type => “Cc”,
Email => $self->TicketObj->OwnerObj-

EmailAddress);
return 1;

Which works perfectly with no weird log messages, but still:

Feb 15 14:42:44 rt RT: About to commit scrips for transaction #458227
Feb 15 14:42:44 rt RT: About to commit scrips for transaction #458226
Feb 15 14:42:44 rt RT:
rt-3.6.3-3363-1171575757-228.41458-2-0@matrixorbital.ca
#41458/458226 - Scrip 2 (//var/www/rt/rt-3.6.3/lib/RT/Action/
SendEmail.pm:243)
Feb 15 14:42:44 rt RT:
rt-3.6.3-3363-1171575757-228.41458-2-0@matrixorbital.ca No
recipients found. Not sending. (//var/www/rt/rt-3.6.3/lib/RT/Action/
SendEmail.pm:255)

I’ve even tried putting my hard-wired email address in the template,
and still refuses to send out the notice.On 15-Feb-07, at 12:16 PM, James McTavish wrote:

We currently use RT for our sales and technical support queries.
Our sales department really doesn’t like having to go through the
browser to do their correspondence, they would prefer just using
email. So I’ve cooked up a quick an dirty method that should
work, if only I could figure it out.

What I would like to happen is that when someone takes a ticket, it
adds them to the CC list and emails them the initial message. This
way all they have to use their browser for is take the ticket.
I’ve been going through the mailing list, and the wiki, cobbling
together something that I thought should work, but alas, it only
partially works. I’m hoping that someone can tell me what I’m
doing wrong, and at least give me a direction to go. For all I
know, I’m overcomplicating things, and there is a MUCH simpler
means to accomplish this.

My scrip so far is:

Condition: User Defined:

my $trans = $self->TransactionObj;
return 0 unless $trans->Field eq ‘Owner’;
return 1 if $trans->OldValue == RT::Nobody( )->id( );
return 0;

Action: User Defined:

Custom action preparation code:
my $new_id = $self->TransactionObj->NewValue;
my $new_user = RT::User->new();
$new_user->Load($new_id);
my $new_email = $new_user->EmailAddress();
$self->TicketObj->AddWatcher( Type => “Cc”,
Email => $new_email);
return 1;

Custom action cleanup code:
return 1;

Template:

To: {$Ticket->OwnerObj->EmailAddress }

{$Ticket->Transactions->First->Content()}

As I’ve said, this only partially works. The new owner does in
fact get added as a CC, however no email is sent. I check the logs
and a few things jump out:

The scip itself generates this warning:

Feb 15 12:08:26 rt RT: at //var/www/rt/rt-3.6.3/lib/RT/Base.pm
line 92
Feb 15 12:08:26 rt RT::Base::CurrentUser(‘RT::User=HASH
(0xf69eb14)’) called at //var/www/rt/rt-3.6.3/lib/RT/Record.pm line 90
Feb 15 12:08:26 rt RT::Record::_Init(‘RT::User=HASH
(0xf69eb14)’) called at //var/www/rt/rt-3.6.3/lib/RT/User.pm line 79
Feb 15 12:08:26 rt RT::User::_Init(‘RT::User=HASH(0xf69eb14)’)
called at /usr/lib/perl5/vendor_perl/5.8.8/DBIx/SearchBuilder/
Record.pm line 362
Feb 15 12:08:26 rt DBIx::SearchBuilder::Record::new
(‘RT::User’) called at (eval 749) line 2
Feb 15 12:08:26 rt eval ’ my $last_id = $self->TransactionObj-

NewValue;
Feb 15 12:08:26 rt my $temp_user = RT::User->new();
Feb 15 12:08:26 rt $temp_user->Load($last_id);
Feb 15 12:08:26 rt my $last_email = $temp_user->EmailAddress();
Feb 15 12:08:26 rt $self->TicketObj->AddWatcher( Type => “Cc”,
Feb 15 12:08:26 rt Email => $last_email);
Feb 15 12:08:26 rt push( @{$self->{'To'}},
Feb 15 12:08:26 rt $self->TicketObj->QueueObj->Cc-
MemberEmailAddresses );
Feb 15 12:08:26 rt return 1;’ called at //var/www/rt/rt-3.6.3/lib/
RT/Action/UserDefined.pm line 63
Feb 15 12:08:26 rt RT::Action::UserDefined::Prepare
(‘RT::Action::UserDefined=HASH(0xf66cec8)’) called at //var/www/rt/
rt-3.6.3/lib/RT/ScripAction_Overlay.pm line 232
Feb 15 12:08:26 rt RT::ScripAction::Prepare
(‘RT::ScripAction=HASH(0xf692ad0)’) called at //var/www/rt/rt-3.6.3/
lib/RT/Scrip_Overlay.pm line 476
Feb 15 12:08:26 rt eval {…} called at //var/www/rt/rt-3.6.3/
lib/RT/Scrip_Overlay.pm line 470
<<>>>
Feb 15 12:08:26 rt RT: RT::User=HASH(0xf69eb14) was created without
a CurrentUser 1 (//var/www/rt/rt-3.6.3/lib/RT/Base.pm:92)

And finishes up with

Feb 15 12:08:26 rt RT: About to think about scrips for transaction
#458213
Feb 15 12:08:26 rt RT: About to prepare scrips for transaction #458213
Feb 15 12:08:26 rt RT: Found 2 scrips
Feb 15 12:08:26 rt RT: About to commit scrips for transaction #458213
Feb 15 12:08:26 rt RT: About to commit scrips for transaction #458212
Feb 15 12:08:26 rt RT:
rt-3.6.3-3363-1171566506-1830.41458-2-0@matrixorbital.ca
#41458/458212 - Scrip 2 (//var/www/rt/rt-3.6.3/lib/RT/Action/
SendEmail.pm:243)
Feb 15 12:08:26 rt RT:
rt-3.6.3-3363-1171566506-1830.41458-2-0@matrixorbital.ca No
recipients found. Not sending. (//var/www/rt/rt-3.6.3/lib/RT/Action/
SendEmail.pm:255)

Any help at all would be greatly appreciated.


-James


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

James McTavish
Director of Research and Development
Matrix Orbital
(403)229-2737x160