Problems writing a ScripCondition: On Merge

I’m trying to write a scrip condition that will trigger on the merge of
a ticket. (The problem I’m solving is that our internal people
frequently get confused looking for tickets they thought they requested,
but which got merged into another ticket; an email to them on the merge
of the ticket would solve thse issues.)

I’ve determined that the description of the “Merge” transaction is
"Merged into ticket #xxx by yyyy" (in this language, anyway), and the
type of transaction is AddLink. I tried the fairly unsophisticated
custom condition:

return undef unless ($self->TransactionObj->Description =~ /^Merge/);
return 1;

but it doesn’t trigger, and the Template doesn’t seem to get quite the
same things as the Condition does. (The wiki suggested I could put
$TransactionObj->Whatever in the template, but that doesn’t actually
work; it gives an error like “Can’t call method “Type” on an undefined
value”.)

I’m familiar with Perl, but not so much with the layout of RT at this
point. Suggestions on where to look for the ‘right’ way to do this?

Thanks!

Justin Larue
CommPartners
(702) 367-VOIP (8647) Phone ext. 1022
(702) 365-VOIP (8647) Fax
jlarue@commpartners.us
www.commpartners.us

Justin Larue wrote:

I’m trying to write a scrip condition that will trigger on the merge of
a ticket. (The problem I’m solving is that our internal people
frequently get confused looking for tickets they thought they requested,
but which got merged into another ticket; an email to them on the merge
of the ticket would solve thse issues.)

I’ve determined that the description of the “Merge” transaction is
"Merged into ticket #xxx by yyyy" (in this language, anyway), and the
type of transaction is AddLink. I tried the fairly unsophisticated
custom condition:

return undef unless ($self->TransactionObj->Description =~ /^Merge/);
return 1;
Description could be localized so you can’t relay on it.
Use next:

my $txn = $self->TransactionObj;
return undef unless $txn->Type =~ /^AddLink$/i;
return undef unless $txn->Field =~ /^MergedInto$/i;
return 1;

but it doesn’t trigger, and the Template doesn’t seem to get quite the
same things as the Condition does. (The wiki suggested I could put
$TransactionObj->Whatever in the template, but that doesn’t actually
work; it gives an error like “Can’t call method “Type” on an undefined
value”.)
You could put { $Transaction->Whatever } in the template. Where exactly
did you see that on wiki?

Thanks for your quick response!

Ruslan U. Zakirov (Ruslan.Zakirov@acronis.com) wrote:

Description could be localized so you can’t relay on it.
Use next:

my $txn = $self->TransactionObj;
return undef unless $txn->Type =~ /^AddLink$/i;
return undef unless $txn->Field =~ /^MergedInto$/i;
return 1;

This works perfectly. Thank you!

You could put { $Transaction->Whatever } in the template. Where
exactly
did you see that on wiki?

http://wiki.bestpractical.com/index.cgi?Template uses both $Transaction
and $TransactionObj in its template examples.

Justin Larue
CommPartners
(702) 367-VOIP (8647) Phone ext. 1022
(702) 365-VOIP (8647) Fax
jlarue@commpartners.us
www.commpartners.us

Justin Larue wrote:

Thanks for your quick response!

Ruslan U. Zakirov (Ruslan.Zakirov@acronis.com) wrote:

Description could be localized so you can’t relay on it.
Use next:

my $txn = $self->TransactionObj;
return undef unless $txn->Type =~ /^AddLink$/i;
return undef unless $txn->Field =~ /^MergedInto$/i;
return 1;

This works perfectly. Thank you!
Wiki update: http://wiki.bestpractical.com/index.cgi?OnMerge

You could put { $Transaction->Whatever } in the template. Where

exactly

did you see that on wiki?

http://wiki.bestpractical.com/index.cgi?Template uses both $Transaction
and $TransactionObj in its template examples.
My fault. Fixed. Thanks for the report.