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
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:
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?)
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
–
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
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
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
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.
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
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