From a template, how do I get a handle to a ticket attachment?

(3.6.0/mysql4/CentOS)

From a template, how can I get at the value of a specific header in the
first email message in a ticket? I know how to get it in a scrip:

my $trans = $self->TransactionObj;
my $msgattr = $trans->Message->First;
my $headerval = $msgattr->GetHeader(‘X-MY-HEADER’);

…but when I try to do that from template context I get this:

[Tue Sep 12 11:33:25 2006] [error]: Template parsing error: Can’t call
method “TransactionObj” on an undefined value at template line 1.

Background: I want to fire a pager if RT gets an email with a particular
value in the “to” header, and I want to extract information from that
header and put it into the email that gets sent to the pager, hence the
need to have a handle to it in the template.

Alternatively, how can I pass a value from a scrip to the template it
calls? I have a scrip with a custom condition that’s firing just fine,
using the snippet above to look for my keyword in the headers of the
email that creates a ticket. If I can pass a variable from that scrip to
the template I wouldn’t need to duplicate the calls…

Thanks for any helpful thoughts,
	Ole

/Ole Craig
Security Engineer
Team lead, customer support

303-381-3802 (main support hotline)
303-381-3824 (my direct line)
303-381-3801 (fax)

www.stillsecure.com
. . .

At Wednesday 9/13/2006 06:42 PM, Ole Craig wrote:

(3.6.0/mysql4/CentOS)

From a template, how can I get at the value of a specific header in the
first email message in a ticket? I know how to get it in a scrip:

my $trans = $self->TransactionObj;
my $msgattr = $trans->Message->First;
my $headerval = $msgattr->GetHeader(‘X-MY-HEADER’);

…but when I try to do that from template context I get this:

[Tue Sep 12 11:33:25 2006] [error]: Template parsing error: Can’t call
method “TransactionObj” on an undefined value at template line 1.

Ole,

You get at objects a bit differently in templates - available to you
is $Ticket, $Transaction etc. So you can replace the first 2 lines
of your code above with:

my $msgattr = $Transaction->Message->First;

The global templates that come with RT are a good reference.

Good luck,
Steve

On Thu, 2006-09-14 at 09:29 -0400, 'twas brillig and Stephen Turner
scrobe:

Ole,

You get at objects a bit differently in templates - available to you
is $Ticket, $Transaction etc. So you can replace the first 2 lines
of your code above with:

my $msgattr = $Transaction->Message->First;

The global templates that come with RT are a good reference.

Good luck,
Steve

Stephen -
Thanks! I could have sworn I’d tried that and got an error, but
apparently not; maybe I fatfingered something last time.

Is there a wikipage or other resource that lists what objects and

structures are inherently available within scrips and templates? I have
the Essentials book, but it’s not much help at that level.

Anyhow, my template is now working:

    my $customername = $msgattr->GetHeader('X-MY-HEADERVAL');
    my $pageraddr = $customername . 'pager@nagios.example.com'; 
    $RT::Logger->warning("using \'$pageraddr\' as pager address;");
    return $pageraddr;}
    RT-Attach-Message: yes
    
    Pager alert from $customername!
    subject given)"}
      Requestors: {$Ticket->RequestorAddresses}
    
    {$Transaction->Content()}


Now I can move on to figuring out how to get Nagios to add a comment to

the ticket when it receives an ACK from the pager.

/Ole Craig
Security Engineer
Team lead, customer support

303-381-3802 (main support hotline)
303-381-3824 (my direct line)
303-381-3801 (fax)

www.stillsecure.com
. . .