Hi Tim,
You know, I’m not sure whether RT will automatically assign a From: and
cleverness, so it wouldn’t surprise me at all if it uses the default queue
address and the ticket subject if you don’t supply them. Try leaving off
the From: and Subject: lines and see what happens.
Otherwise, you’d want something like this:
my $from_address = ‘rt@myorg.org’;
my $subject = $Ticket->Transactions->First->Subject;
And yes, you need to make a new template for this. Make sure you don’t
have any blank lines at the top of the template.
So, putting it all together (more or less), your template would consist of
everything between the ===== lines below
{ ### Template for notifying campus techs
my $bldg = $Ticket->FirstCustomFieldValue(‘Building’);
my $group = RT::Group->new( $RT::SystemUser );
$group->LoadUserDefinedGroup(“SupportTeam-$group”);
my $addresslist = $group->MemberEmailAddressesAsString;
$OUT = "To: addresslist
Boilerplate text goes here.
Have a nice day,
The RT ticketing system
";
}
Robert Long added to this thread with a suggestion that might make your
template even simpler. He’s put all of the perl code right after To: and
then the rest of the template is just static text. Using his suggestion,
your template would look like the stuff between the ===== lines below
my $group = RT::Group->new( $RT::SystemUser );
$group->LoadUserDefinedGroup(“SupportTeam-$bldg”);
$group->MemberEmailAddressesAsString;}
Boilerplate text goes here.
Have a nice day,
The RT ticketing system
I prefer building the entire message inside my { perl code } like the first
template because I usually put dynamic stuff inside the message body and
it’s easier for me to follow what I’m doing if I know that the only thing
that is going to be sent is in $OUT. But that’s just the way my mind works.
Gene
At 08:45 PM 8/22/2007, Tim Wilson wrote:> >>> On Wed, Aug 22, 2007 at 4:40 PM, in message 6.2.1.2.2.20070822141126.025eacc8@mail.sdsu.edu, Gene LeDuc gleduc@mail.sdsu.edu wrote:
In your template you get the value of the field with:
my $bldg = $Ticket- >FirstCustomFieldValue(‘Building’);
Then you do the e- mail:
$OUT = "From: $from_address
To: $addresslist
Subject: $subject
Boilerpalte text goes here.
";
Gene,
Is there something magic about $from_address and $subject or do I need to
create those variables? I’m assuming that I can’t use the built-in RT
templates for those since I’m adding all this perl to the template.
My template now looks like this:
my $bldg = $Ticket->FirstCustomFieldValue(‘Building’);
my $group = RT::Group->new( $RT::SystemUser );
$group->LoadUserDefinedGroup(“SupportTeam-$group”);
my $addresslist = $group->MemberEmailAddressesAsString;
$OUT = "From: $from_address
To: $addresslist
Subject: $subject
This is a test message.
";
This isn’t working, and I get the following error in the RT log:
Aug 22 22:37:43 support RT: error: couldn’t parse head; error near: my
$bldg
= $Ticket->FirstCustomFieldValue(‘Building’); my $group = RT::Group->new(
$RT::S
ystemUser ); $group->LoadUserDefinedGroup(“SupportTeam-$group”); my
$addresslist
= $group->MemberEmailAddressesAsString;
(/usr/local/rt3/lib/RT/Template_Overlay
.pm:336)
So obviously the message isn’t being generated correctly. I’ve been
scouring the wiki looking for other template examples that use this sort
of method, but I’m not having much luck making sense of them. Any help
would be greatly appreciated.
-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