Template won't fire when scrip condition is true

Hi All,

I’ve been scratching my head over this for 2 days and haven’t been able to
solve it. I have a scrip that is not firing the Notify Others action when
its user-defined condition is true. The scrip fires, the condition is
true, but the execution chain simply ends without the template getting
launched. There are no errors in the apache log and my debug log shows
that the scrip condition is true. I have an almost identical scrip
(different code for conditional and template) in another queue that is
working fine, so I’m taking a step back and asking if anyone here can see
my mistakes.

  1. An e-mail is sent to RT and data is extracted from it and loaded into
    custom fields in the newly created ticket. This is working; the ticket
    gets created and all of the custom fields get their correct data.
  2. Setting one of the custom fields (above) causes a user-defined condition
    in another scrip to fire. The scrip looks like this:
    Description: Ack Requestor
    Condition: User Defined
    { ### True when machine name is first set (set by New Ticket scrip)
    my $MyName = “Scrip DNS:37:Condition (Ack Requestor)”;
    my $Transaction = $self->TransactionObj;
    my $field = 7;
    my $val = ($Transaction->Type =~ /CustomField/i) &&
    ($Transaction->Field == $field) && !$Transaction->OldValue();
    $RT::Logger->debug(“$MyName: Conditional is $val”);
    return $val;
    }
    Action: Notify Other Recipients
    Template: Acknowledge
    Stage: TransactionCreate

I know that the scrip is firing because of the $RT::Logger->debug statement
(just before the return in the condition code), and I know that the return
value is 1 for the same reason. Here is the log entry:
[Tue Apr 17 17:40:56 2007] [debug]: Scrip DNS:37:Condition (Ack Requestor):
Conditional is 1 ((eval 900):8)

Since the returned value ($val) is 1, the Acknowledge template should get
run, but it doesn’t. I’m certain of this because the first line of the
template is:
{ $RT::Logger->debug(“Template DNS:26 (Acknowledge): Entering template”);
and nothing gets logged.

Here is the debug log for this run (Transaction 3237 is the ticket creation
and 3238 is the custom field being populated):
[Tue Apr 17 17:40:54 2007] [debug]: About to think about scrips for
transaction #3233 (/opt/local/lib/RT/Transaction_Overlay.pm:165)
[Tue Apr 17 17:40:54 2007] [debug]: About to think about scrips for
transaction #3234 (/opt/local/lib/RT/Transaction_Overlay.pm:165)
[Tue Apr 17 17:40:54 2007] [debug]: About to think about scrips for
transaction #3235 (/opt/local/lib/RT/Transaction_Overlay.pm:165)
[Tue Apr 17 17:40:54 2007] [debug]: About to think about scrips for
transaction #3236 (/opt/local/lib/RT/Transaction_Overlay.pm:165)
[Tue Apr 17 17:40:54 2007] [debug]: About to think about scrips for
transaction #3237 (/opt/local/lib/RT/Transaction_Overlay.pm:165)
[Tue Apr 17 17:40:54 2007] [debug]: About to prepare scrips for transaction
#3237 (/opt/local/lib/RT/Transaction_Overlay.pm:169)
[Tue Apr 17 17:40:54 2007] [debug]: Found 4 scrips
(/opt/local/lib/RT/Scrips_Overlay.pm:363)
[Tue Apr 17 17:40:54 2007] [debug]: Scrip DNS:37:Condition (Ack Requestor):
Conditional is ((eval 890):8)
[Tue Apr 17 17:40:54 2007] [debug]: About to commit scrips for transaction
#3237 (/opt/local/lib/RT/Transaction_Overlay.pm:178)
[Tue Apr 17 17:40:56 2007] [debug]: About to think about scrips for
transaction #3238 (/opt/local/lib/RT/Transaction_Overlay.pm:165)
[Tue Apr 17 17:40:56 2007] [debug]: About to prepare scrips for transaction
#3238 (/opt/local/lib/RT/Transaction_Overlay.pm:169)
[Tue Apr 17 17:40:56 2007] [debug]: Found 3 scrips
(/opt/local/lib/RT/Scrips_Overlay.pm:363)
[Tue Apr 17 17:40:56 2007] [debug]: Scrip DNS:37:Condition (Ack Requestor):
Conditional is 1 ((eval 900):8)
[Tue Apr 17 17:40:56 2007] [debug]: About to commit scrips for transaction
#3238 (/opt/local/lib/RT/Transaction_Overlay.pm:178)
[Tue Apr 17 17:40:56 2007] [info]: Ticket 313 created in queue ‘DNS’ by
bogus.user@bogus.domain.com (/opt/local/lib/RT/Ticket_Overlay.pm:754)
[Tue Apr 17 17:40:57 2007] [debug]: Found 0 scrips
(/opt/local/lib/RT/Scrips_Overlay.pm:363)

Can someone point out what I’m missing here?

Thanks,
Gene

At Tuesday 4/17/2007 02:00 PM, Gene LeDuc wrote:

Hi All,

I’ve been scratching my head over this for 2 days and haven’t been
able to solve it. I have a scrip that is not firing the Notify
Others action when its user-defined condition is true. The scrip
fires, the condition is true, but the execution chain simply ends
without the template getting launched. There are no errors in the
apache log and my debug log shows that the scrip condition is
true. I have an almost identical scrip (different code for
conditional and template) in another queue that is working fine, so
I’m taking a step back and asking if anyone here can see my mistakes.

Gene,

What does the Acknowledge template look like? You’ll need recipients
coded in the template to generate any email from this setup.

Steve

Gene,

I'm certainly no expert, but usually it's the simple assumed things 

that bite us. You’re stated
"Since the returned value ($val) is 1, the Acknowledge template should
get run, but it doesn’t. I’m certain of this because the first line of
the template is:
{ $RT::Logger->debug(“Template DNS:26 (Acknowledge): Entering template”);
and nothing gets logged."
It looks to me like you’re missing a right parenthesis, but maybe you
only showed part of the code. Just a thought.

Kenn
LBNL

Gene LeDuc wrote:

The Acknowledge template builds the $OUT variable, and the first part of
that happens kind of deeply in the template code. When I finally get to
it, it goes like this:
$OUT = "To: $uEmail

A request to register a DNS entry has been received by the IT Security
Office with the following information:
blah blah blah";

In the past when I’ve had a problem with templates, RT has been pretty
forthcoming with error messages. I’m not seeing any and the log entry at
the beginning of the code never gets logged, so my conclusion is that the
template is never getting “run”.

If the template was messed up somehow, is there a way to show that it’s
actually being run and silently failing (other than logging debug
statements at the beginning)?

At 11:08 AM 4/17/2007, Stephen Turner wrote:

At Tuesday 4/17/2007 02:00 PM, Gene LeDuc wrote:

Hi All,

I’ve been scratching my head over this for 2 days and haven’t been able
to solve it. I have a scrip that is not firing the Notify Others action
when its user-defined condition is true. The scrip fires, the condition
is true, but the execution chain simply ends without the template getting
launched. There are no errors in the apache log and my debug log shows
that the scrip condition is true. I have an almost identical scrip
(different code for conditional and template) in another queue that is
working fine, so I’m taking a step back and asking if anyone here can see
my mistakes.

Gene,

What does the Acknowledge template look like? You’ll need recipients coded
in the template to generate any email from this setup.

Steve

Gene LeDuc, GSEC
Security Analyst
San Diego State University

I just tried hard-coding the headers into the template like so (minus the
“begin” and “end” lines):
========= begin template

{ $RT::Logger->debug(“Template DNS:26 (Acknowlege): Entering template”);
#(more template code goes here)
}
========= end template

Still no e-mail. I’m convince that the template is not getting run. But
RT is indicating that it should be.

At 11:08 AM 4/17/2007, Stephen Turner wrote:

At Tuesday 4/17/2007 02:00 PM, Gene LeDuc wrote:

Hi All,

I’ve been scratching my head over this for 2 days and haven’t been able
to solve it. I have a scrip that is not firing the Notify Others action
when its user-defined condition is true. The scrip fires, the condition
is true, but the execution chain simply ends without the template getting
launched. There are no errors in the apache log and my debug log shows
that the scrip condition is true. I have an almost identical scrip
(different code for conditional and template) in another queue that is
working fine, so I’m taking a step back and asking if anyone here can see
my mistakes.

Gene,

What does the Acknowledge template look like? You’ll need recipients coded
in the template to generate any email from this setup.

Steve

Gene LeDuc, GSEC
Security Analyst
San Diego State University

I figured out the problem (a template attached to a scrip whose condition
was true wasn’t being run). The problem was in the template; I had typed a
“(” instead of a “{” in an if-else block. RT wasn’t catching that there
was an unmatched curly brace and an unmatched open parenthesis in the
template and neither was I.

Thanks to all who took the time to help me on this!

At 12:19 PM 4/17/2007, Gene LeDuc wrote:

I just tried hard-coding the headers into the template like so (minus the
“begin” and “end” lines):
========= begin template
To: myaddress@mydomain.whatever
Subject: Is the template firing?

{ $RT::Logger->debug(“Template DNS:26 (Acknowlege): Entering template”);
#(more template code goes here)
}
========= end template

Still no e-mail. I’m convince that the template is not getting run. But
RT is indicating that it should be.

At 11:08 AM 4/17/2007, Stephen Turner wrote:

At Tuesday 4/17/2007 02:00 PM, Gene LeDuc wrote:

Hi All,

I’ve been scratching my head over this for 2 days and haven’t been able
to solve it. I have a scrip that is not firing the Notify Others action
when its user-defined condition is true. The scrip fires, the condition
is true, but the execution chain simply ends without the template
getting launched. There are no errors in the apache log and my debug
log shows that the scrip condition is true. I have an almost identical
scrip (different code for conditional and template) in another queue
that is working fine, so I’m taking a step back and asking if anyone
here can see my mistakes.

Gene,

What does the Acknowledge template look like? You’ll need recipients
coded in the template to generate any email from this setup.

Steve


Gene LeDuc, GSEC
Security Analyst
San Diego State University


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