Triggering scrips on add/delete Ccs

Hey everyone,

I’ve been beating my head against the wall trying to figure out an answer to the question I posted yesterday:

Maybe I’m approaching this the wrong way, but I haven’t been able to find out how to write a custom scrip condition that triggers when a CC is added to a ticket. (The flip side is triggering when a CC is removed.)

Any ideas? This seems like it should be easy. What TransactionObj->Type would correspond to adding a CC? (And where should I be looking to find out about possible values for things like TransactionObj-Type?)

Hoping someone has a clue they can loan me,
Tim

Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE Buffalo, MN 55313
ph: 763.682.8740 fax: 763.682.8743 http://www.buffalo.k12.mn.us

These should be what you’re looking for:

TransactionObj->Type->AddWatcher
or TransactionObj->Type->DelWatcher

Del may be Delete for scrips-- I’m not sure. I pulled these two types from
the Transactions table right in MySql… I don’t know if there’s a better
place to find such things.

Forrest

Hey everyone,

I’ve been beating my head against the wall trying to figure out an answer
to the question I posted yesterday:

Carbon60: Managed Cloud Services

Maybe I’m approaching this the wrong way, but I haven’t been able to find
out how to write a custom scrip condition that triggers when a CC is added
to a ticket. (The flip side is triggering when a CC is removed.)

Any ideas? This seems like it should be easy. What TransactionObj->Type
would correspond to adding a CC? (And where should I be looking to find out
about possible values for things like TransactionObj-Type?)

Hoping someone has a clue they can loan me,

These should be what you’re looking for:

TransactionObj- >Type- >AddWatcher
or TransactionObj- >Type- >DelWatcher

That helps. I found that this will trigger when any watchers are added:

return undef unless ( $self->TransactionObj->Type eq “AddWatcher” );
return 1;

I haven’t been able to figure out how to specify that I’m only interested in new Ccs, not any old watcher. This doesn’t work:

return undef unless ( $self->TransactionObj->Type->AddWatcher->Type eq “Cc” );
return 1;

Neither does this:

return undef unless ( $self->TransactionObj->Type->AddWatcher(Type=>“Cc” );
return 1;

-Tim

Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE Buffalo, MN 55313
ph: 763.682.8740 fax: 763.682.8743 http://www.buffalo.k12.mn.us

Try
return $self->TransactionObj->Type eq “AddWatcher” &&
$self->TransactionObj->Field eq “Cc”;

At 02:15 PM 10/18/2007, Tim Wilson wrote:> >>> On Thu, Oct 18, 2007 at 3:35 PM, in message e99ac1500710181335l2510db86h5afe1199eb6b1acc@mail.gmail.com, “Forrest Blount” forrestarthur@gmail.com wrote:

These should be what you’re looking for:

TransactionObj- >Type- >AddWatcher
or TransactionObj- >Type- >DelWatcher

That helps. I found that this will trigger when any watchers are added:

return undef unless ( $self->TransactionObj->Type eq “AddWatcher” );
return 1;

I haven’t been able to figure out how to specify that I’m only interested
in new Ccs, not any old watcher. This doesn’t work:

return undef unless ( $self->TransactionObj->Type->AddWatcher->Type eq “Cc” );
return 1;

Neither does this:

return undef unless ( $self->TransactionObj->Type->AddWatcher(Type=>“Cc” );
return 1;

-Tim


Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE Buffalo, MN 55313
ph: 763.682.8740 fax: 763.682.8743 http://www.buffalo.k12.mn.us


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

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Try
return $self- >TransactionObj- >Type eq “AddWatcher” &&
$self- >TransactionObj- >Field eq “Cc”;

I thought that would work, but I got this error in the log:

Oct 18 16:31:28 support RT: Scrip 39 IsApplicable failed: Unrecognized character \xE2 at (eval 678) line 1. Stack: [(eval 678):1] [/usr/local/rt3/lib/RT/ScripCondition_Overlay.pm:219] [/usr/local/rt3/lib/RT/Scrip_Overlay.pm:437] [/usr/local/rt3/lib/RT/Scrips_Overlay.pm:230] [/usr/local/rt3/lib/RT/Transaction_Overlay.pm:171] [/usr/local/rt3/lib/RT/Record.pm:1444] [/usr/local/rt3/lib/RT/Ticket_Overlay.pm:1447] [/usr/local/rt3/lib/RT/Ticket_Overlay.pm:1387] [/usr/local/rt3/lib/RT/Interface/Web.pm:1432] [/usr/local/rt3/share/html/Ticket/ModifyPeople.html:73] [/usr/local/rt3/share/html/autohandler:292] (/usr/local/rt3/lib/RT/Condition/UserDefined.pm:67)

I did manage to find something that seems to work though. It was posted on the list back in January, 2007.

I tweaked it to look for Cc instead of AdminCc and got:

my $transactionType = $self->TransactionObj->Type;
my $watcherType = $self->TransactionObj->Field;
if (($transactionType eq ‘AddWatcher’) and ($watcherType eq ‘Cc’)) {
return 1;
}
return undef;

That definitely does the trick. Now I just need to figure out how to send email to the newly minted Cc and not the whole group of Ccs. Thanks for the help Gene and Forrest.

-Tim

Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE Buffalo, MN 55313
ph: 763.682.8740 fax: 763.682.8743 http://www.buffalo.k12.mn.us

Did you copy in the space in the “- >”? There should be no white space
there in your Perl code. It should look like “->”.

Just an attempt at an easy answer.

KeithFrom: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Tim
Wilson
Sent: Thursday, October 18, 2007 4:37 PM
To: Gene LeDuc
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Triggering scrips on add/delete Ccs

Try
return $self- >TransactionObj- >Type eq “AddWatcher” &&
$self- >TransactionObj- >Field eq “Cc”;

I thought that would work, but I got this error in the log:

Oct 18 16:31:28 support RT: Scrip 39 IsApplicable failed: Unrecognized
character \xE2 at (eval 678) line 1. Stack: [(eval 678):1]
[/usr/local/rt3/lib/RT/ScripCondition_Overlay.pm:219]
[/usr/local/rt3/lib/RT/Scrip_Overlay.pm:437]
[/usr/local/rt3/lib/RT/Scrips_Overlay.pm:230]
[/usr/local/rt3/lib/RT/Transaction_Overlay.pm:171]
[/usr/local/rt3/lib/RT/Record.pm:1444]
[/usr/local/rt3/lib/RT/Ticket_Overlay.pm:1447]
[/usr/local/rt3/lib/RT/Ticket_Overlay.pm:1387]
[/usr/local/rt3/lib/RT/Interface/Web.pm:1432]
[/usr/local/rt3/share/html/Ticket/ModifyPeople.html:73]
[/usr/local/rt3/share/html/autohandler:292]
(/usr/local/rt3/lib/RT/Condition/UserDefined.pm:67)

I did manage to find something that seems to work though. It was posted
on the list back in January, 2007.

I tweaked it to look for Cc instead of AdminCc and got:

my $transactionType = $self->TransactionObj->Type; my $watcherType =
$self->TransactionObj->Field; if (($transactionType eq ‘AddWatcher’) and
($watcherType eq ‘Cc’)) { return 1; } return undef;

That definitely does the trick. Now I just need to figure out how to
send email to the newly minted Cc and not the whole group of Ccs. Thanks
for the help Gene and Forrest.

-Tim

Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE Buffalo, MN 55313
ph: 763.682.8740 fax: 763.682.8743 http://www.buffalo.k12.mn.us

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

I’d check that there were no typos or extraneous characters in the
condition code. What you found and is working for you is essentially the
same thing that I posted, minus the intermediate assignments to
$transactionType and $watcherType. The error message about the
unrecognized \xE2 character seems to indicate that there was something odd
in what it was trying to evaluate, maybe in the first line of scrip 39.

At 02:37 PM 10/18/2007, Tim Wilson wrote:> >>> On Thu, Oct 18, 2007 at 4:25 PM, in message 6.2.1.2.2.20071018142052.0267ed40@mail.sdsu.edu, Gene LeDuc gleduc@mail.sdsu.edu wrote:

Try
return $self- >TransactionObj- >Type eq “AddWatcher” &&
$self- >TransactionObj- >Field eq “Cc”;

I thought that would work, but I got this error in the log:

Oct 18 16:31:28 support RT: Scrip 39 IsApplicable failed: Unrecognized
character \xE2 at (eval 678) line 1. Stack: [(eval
678):1] [/usr/local/rt3/lib/RT/ScripCondition_Overlay.pm:219]
[/usr/local/rt3/lib/RT/Scrip_Overlay.pm:437]
[/usr/local/rt3/lib/RT/Scrips_Overlay.pm:230]
[/usr/local/rt3/lib/RT/Transaction_Overlay.pm:171]
[/usr/local/rt3/lib/RT/Record.pm:1444]
[/usr/local/rt3/lib/RT/Ticket_Overlay.pm:1447]
[/usr/local/rt3/lib/RT/Ticket_Overlay.pm:1387]
[/usr/local/rt3/lib/RT/Interface/Web.pm:1432]
[/usr/local/rt3/share/html/Ticket/ModifyPeople.html:73]
[/usr/local/rt3/share/html/autohandler:292]
(/usr/local/rt3/lib/RT/Condition/UserDefined.pm:67)

I did manage to find something that seems to work though. It was posted on
the list back in January, 2007.

Carbon60: Managed Cloud Services

I tweaked it to look for Cc instead of AdminCc and got:

my $transactionType = $self->TransactionObj->Type;
my $watcherType = $self->TransactionObj->Field;
if (($transactionType eq ‘AddWatcher’) and ($watcherType eq ‘Cc’)) {
return 1;
}
return undef;

That definitely does the trick. Now I just need to figure out how to send
email to the newly minted Cc and not the whole group of Ccs. Thanks for
the help Gene and Forrest.

-Tim


Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE Buffalo, MN 55313
ph: 763.682.8740 fax: 763.682.8743 http://www.buffalo.k12.mn.us

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Hey everyone,

For the sake of completeness and mailing list documentation, here’s the snippet of code I’m using in my template to send an email to each new CC alerting them that they’ve been added to the ticket. The same code would work any time a new watcher is added to a ticket. If you use OldValue instead, I think it would also work for notifying watchers that they’ve been removed from a ticket.

To: {
my $watcherid = $Transaction->NewValue;
my $user = RT::User->new( $RT::SystemUser );
$user->Load( $watcherid );
$user->EmailAddress;
}

The $watcherid value is the user id of the person added as CC. Thanks to everyone who responded to my original question.

-Tim

Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE Buffalo, MN 55313
ph: 763.682.8740 fax: 763.682.8743 http://www.buffalo.k12.mn.us