Template help REALLY required

Folks,

I’ve been pushing RT here to the department I’m working in, saying that it
can implement just about any workflow required. But I can’t seem to get the
templates working properly and now I’m faced with having egg on my face
because RT just doesn’t seem to work.

My scenario is this: A user creates a ticket in a queue. An approval is
created that is sent to the originator’s supervisor. The relationship
between requester and their supervisor is held in an external system. I can
get the block of code in the template to lookup the supervisor, but I cannot
get it to assign the supervisor as the AdminCc in the approval template. Eg:

===Create-Ticket: approval
{
   ... Lookup code...
   my @admins;
   push (@admins, "supervisor's email address");
}
AdminCc: {join ("\nAdminCc: ",@admins) }

The example template does something extremely similar to this
(http://www.bestpractical.com/rt/docs/3.0/appendix5-approvals.txt). The
example populates an array called “@admins” which is used later to assign to
the “AdminCc:” section of the template. However this does not work for
me… the value of “@admins” is NOT passed through… it just turns out
blank.

I asked this question before, but no answers were forthcoming. Does anybody
know how to resolve this? Has anybody used variables/arrays in their
templates in this manner? Can anybody confirm/deny whether this works? Am
I asking the wrong mailing list? Should I ask rt-devel?

Damien Lederer

Solaris Administrator
ITSA Information Technology

Lederer, Damien a écrit :

[snip]
===Create-Ticket: approval
{
… Lookup code…
my @admins;
push (@admins, “supervisor’s email address”);
}
AdminCc: {join ("\nAdminCc: ",@admins) }

The example template does something extremely similar to this
(http://www.bestpractical.com/rt/docs/3.0/appendix5-approvals.txt). The
example populates an array called “@admins” which is used later to assign to
the “AdminCc:” section of the template. However this does not work for
me… the value of “@admins” is NOT passed through… it just turns out
blank.

I asked this question before, but no answers were forthcoming. Does anybody
know how to resolve this? Has anybody used variables/arrays in their
templates in this manner? Can anybody confirm/deny whether this works? Am
I asking the wrong mailing list? Should I ask rt-devel?

Each template code block corresponds is translated into a real Perl
block. So I think your problem may be related to using “my @admins
between braces: the list @admins is syntaxically scoped to the frist
block and thus is out of scope of the second block.

You can either try to use only one block :

{
… Lookup code…
my @admins;
push (@admins, “supervisor’s email address”);
$OUT = map “\nAdminCc: $_”, @admins;
}

(see Text::Template man page for usage of the $OUT variable).

Or omit the my() statement :

{
… Lookup code…
@admins = (); # Even this can be facultative, depending of leading code
push (@admins, “supervisor’s email address”);
}
AdminCc: {join ("\nAdminCc: ",@admins) }

Guillaume Perréal.

Responsable informatique,
Cemagref, groupement de Lyon,
France.

Tél: (+33) 4.72.20.87.87.
Fax: (+33) 4.78.47.78.75.
Site: http://www.lyon.cemagref.fr/