CFs in Templates?

According to Template Fields - Request Tracker Wiki
“Key Name Meaning
CustomField-<id#> => custom field value”

But creating a per-queue ‘Correspondence’ template which looks exactly
like the Global ‘Correspondence’ template with
CustomField-10: yes
CustomField-18: yes
prepended (or just
CustomField-10
CustomField-18
)

just ends me up with a mail message with the lines
Customfield-10: yes
Customfield-18: yes

in the headers.

Neither
http://wiki.bestpractical.com/view/Template
nor Template_Fields discuss a more detailed mechanism for pulling this
data out of a ticket and in to mail.

Any help will be much appreciated.
JB
JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com

I’m not sure what your end goal is, but I use the following subroutine in
my templates when I need to get CFs. It’s mostly from various wiki examples.

Returns custom field value

get_custom($field_name)

sub get_custom {
my $target_name = $_[0];
my $val = $Ticket->FirstCustomFieldValue($target_name);
return $val if defined $val;
return undef;
}

If your CF is named “blahblah” then you get the value with
$cfval = get_custom(‘blahblah’);

Returns undef if it’s not allowed to get the CF or it doesn’t exist.

Regards,
Gene

At 07:29 AM 12/13/2007, JB Segal wrote:

According to Template Fields - Request Tracker Wiki
“Key Name Meaning
CustomField-<id#> => custom field value”

But creating a per-queue ‘Correspondence’ template which looks exactly
like the Global ‘Correspondence’ template with
CustomField-10: yes
CustomField-18: yes
prepended (or just
CustomField-10
CustomField-18
)

just ends me up with a mail message with the lines
Customfield-10: yes
Customfield-18: yes

in the headers.

Neither
Template - Request Tracker Wiki
nor Template_Fields discuss a more detailed mechanism for pulling this
data out of a ticket and in to mail.

Any help will be much appreciated.
JB

JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com


The rt-users Archives

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we’ll take
up to 20 percent off the price. This sale won’t last long, so get in touch
today.
Email us at sales@bestpractical.com or call us at +1 617 812 0745.

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

Quoth Gene LeDuc (gleduc@mail.sdsu.edu):

I’m not sure what your end goal is, but I use the following subroutine in my templates when I need to

My goal is to give people things to sort on in their mailer, such that
they can better manage the flood of incoming mail.

get CFs. It’s mostly from various wiki examples.

Returns custom field value

get_custom($field_name)

sub get_custom {
my $target_name = $_[0];
my $val = $Ticket->FirstCustomFieldValue($target_name);
return $val if defined $val;
return undef;
}

If your CF is named “blahblah” then you get the value with
$cfval = get_custom(‘blahblah’);

Returns undef if it’s not allowed to get the CF or it doesn’t exist.

Regards,
Gene

So how does this mesh with the below-quoted Template Field
‘CustomField-<id#>’? It looks like that’s just supposed to Do The
Right Thing, but it obviously doesn’t.

Oh! Or is this a poor naming thing, and really the template field
should be named something more like CustomHeader or some such?

JB

At 07:29 AM 12/13/2007, JB Segal wrote:

According to Template Fields - Request Tracker Wiki
“Key Name Meaning
CustomField-<id#> => custom field value”

But creating a per-queue ‘Correspondence’ template which looks exactly
like the Global ‘Correspondence’ template with
CustomField-10: yes
CustomField-18: yes
prepended (or just
CustomField-10
CustomField-18
)

just ends me up with a mail message with the lines
Customfield-10: yes
Customfield-18: yes

in the headers.

Neither
Template - Request Tracker Wiki
nor Template_Fields discuss a more detailed mechanism for pulling this
data out of a ticket and in to mail.

Any help will be much appreciated.
JB

JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com


The rt-users Archives

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we’ll take
up to 20 percent off the price. This sale won’t last long, so get in touch today.
Email us at sales@bestpractical.com or call us at +1 617 812 0745.

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
JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com

At Thursday 12/13/2007 12:07 PM, JB Segal wrote:

So how does this mesh with the below-quoted Template Field
’CustomField-<id#>’? It looks like that’s just supposed to Do The
Right Thing, but it obviously doesn’t.

Oh! Or is this a poor naming thing, and really the template field
should be named something more like CustomHeader or some such?

JB

I think there’s some confusion with the term “template”. The word is
used for two completely different areas of RT functionality:

  1. To describe predefined outgoing email message specifications (as
    in Config -> Global -> Templates)
  2. To define data-upload format (Tools->Offline)

The code Gene posted relates to 1 whereas the CustomField-<id#>
specifier relates to 2.

Steve

Thanks for clearing that up, Steve. I wasn’t aware of #2.

Gene

At 09:34 AM 12/13/2007, Stephen Turner wrote:

At Thursday 12/13/2007 12:07 PM, JB Segal wrote:

So how does this mesh with the below-quoted Template Field
’CustomField-<id#>’? It looks like that’s just supposed to Do The
Right Thing, but it obviously doesn’t.

Oh! Or is this a poor naming thing, and really the template field
should be named something more like CustomHeader or some such?

JB

I think there’s some confusion with the term “template”. The word is used
for two completely different areas of RT functionality:

  1. To describe predefined outgoing email message specifications (as in
    Config -> Global -> Templates)
  2. To define data-upload format (Tools->Offline)

The code Gene posted relates to 1 whereas the CustomField-<id#> specifier
relates to 2.

Steve

Gene LeDuc, GSEC
Security Analyst
San Diego State University

Quoth Stephen Turner (sturner@MIT.EDU):

At Thursday 12/13/2007 12:07 PM, JB Segal wrote:

So how does this mesh with the below-quoted Template Field
‘CustomField-<id#>’? It looks like that’s just supposed to Do The
Right Thing, but it obviously doesn’t.

Oh! Or is this a poor naming thing, and really the template field
should be named something more like CustomHeader or some such?

JB

I think there’s some confusion with the term “template”. The word is used for two completely different
areas of RT functionality:

  1. To describe predefined outgoing email message specifications (as in Config → Global → Templates)
  2. To define data-upload format (Tools->Offline)

The code Gene posted relates to 1 whereas the CustomField-<id#> specifier relates to 2.

I don’t think that your last sentence here is right…
The 2nd wiki page I mentioned,
http://wiki.bestpractical.com/view/Template
says in part:
What fields can at Template have?

A template can have a large number of fields. Look at the article
Template_Fields for more information.

What if I want to override a Global Template for one of my queues?

Templates are attached to Scrips by name - meaning that if you define a
Queue Template with the same name as a Global Template, when a Scrip is
triggered it will use the Queue Template instead.

One example would be to create a Queue Template called ‘Correspondence’.
The various global Scrips that use the Correspondence template will use
our new template, not the global template of the same name.
= = =
and the 3rd line of my quote links to my 1st linked page,
http://wiki.bestpractical.com/view/Template_Fields

Now, it’s not impossible that the content of Template_Fields is
incorrect, as this IS a wiki and all that, but either the page needs
some SERIOUS correcting, or someoneone thinks that this is supposed to
be part of an email-generating system.

Either’s fine by me, but I’d really love to know which. :slight_smile:

JB

Steve
JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com

At Thursday 12/13/2007 01:15 PM, JB Segal wrote:

I don’t think that your last sentence here is right…
The 2nd wiki page I mentioned,
Template - Request Tracker Wiki
says in part:
What fields can at Template have?

A template can have a large number of fields. Look at the article
Template_Fields for more information.

The wiki page is wrong - the Template_Fields page refers to the file
upload template.

Steve

JB,

Here is a copy of a "Template" I use. In this template, I am grabbing a 

Custom Field (named ‘Description’) and printing it in the body of an email:

TICKET INFORMATION:
Ticket Queue : {$Ticket->QueueObj->Name}
Ticket Number : #{$Ticket->id}
Ticket Subject: {$Ticket->Subject}
Ticket Description:
{
return $Ticket->FirstCustomFieldValue(‘Description’);
}
Ticket Priority is: {$Ticket->Priority}
Ticket Created by: {$Ticket->CreatorObj->Name}
Ticket Created on: {substr($Ticket->Created, 0, 10)}

This "Template" could also serve as an example of how to just pull 

different “Ticket” information and put it into an email. Take particular
notice of the blank line between the subject (a header) line and the
body of the template (I like to put in a dashed line, for effect). RT
has default header info and by using the name of the header line (i.e.
“Subject:”) I am essentially overriding that default. However, RT needs
for me to put a blank line between any header line overrides and the
body so it can tell the difference. Otherwise, it won’t work. Hope this
helps.

Kenn
LBNLOn 12/13/2007 10:15 AM, JB Segal wrote:

Quoth Stephen Turner (sturner@MIT.EDU):

At Thursday 12/13/2007 12:07 PM, JB Segal wrote:

So how does this mesh with the below-quoted Template Field
‘CustomField-<id#>’? It looks like that’s just supposed to Do The
Right Thing, but it obviously doesn’t.

Oh! Or is this a poor naming thing, and really the template field
should be named something more like CustomHeader or some such?

JB
I think there’s some confusion with the term “template”. The word is used for two completely different
areas of RT functionality:

  1. To describe predefined outgoing email message specifications (as in Config → Global → Templates)
  2. To define data-upload format (Tools->Offline)

The code Gene posted relates to 1 whereas the CustomField-<id#> specifier relates to 2.

I don’t think that your last sentence here is right…
The 2nd wiki page I mentioned,
Template - Request Tracker Wiki
says in part:
What fields can at Template have?

A template can have a large number of fields. Look at the article
Template_Fields for more information.

What if I want to override a Global Template for one of my queues?

Templates are attached to Scrips by name - meaning that if you define a
Queue Template with the same name as a Global Template, when a Scrip is
triggered it will use the Queue Template instead.

One example would be to create a Queue Template called ‘Correspondence’.
The various global Scrips that use the Correspondence template will use
our new template, not the global template of the same name.
= = =
and the 3rd line of my quote links to my 1st linked page,
Template Fields - Request Tracker Wiki

Now, it’s not impossible that the content of Template_Fields is
incorrect, as this IS a wiki and all that, but either the page needs
some SERIOUS correcting, or someoneone thinks that this is supposed to
be part of an email-generating system.

Either’s fine by me, but I’d really love to know which. :slight_smile:

JB

Steve

JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com


The rt-users Archives

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we’ll take
up to 20 percent off the price. This sale won’t last long, so get in touch today.
Email us at sales@bestpractical.com or call us at +1 617 812 0745.

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

Kenn,
This is fabulous! Thank you so much.
Would you mind me sticking this in to the wiki to fix the broken
information that’s in there?

Everyone: Is there a matrix (simpler than grovelling through all the
perldoc that’s out there) of all the objects you can pull out of a
ticket/stick in to a template/scrip/etc? Have I just not found it in the
wiki yet?

JB

Quoth Kenneth Crocker (KFCrocker@lbl.gov):

JB,

Actually, all I did in that Template is use information that is already 

in one example or another on the wiki. Gene LeDuc was a HUGE help in
understanding how some of this works in scrips and templates. I can only
assume a lot of his understanding came from stuff already in the wiki as
well. My biggest learning curve was in understanding how to find stuff
in the wiki and learning the many variations of PERL code that can
accomplish the same thing. I’m not sure that the info on THIS type of
template in the wiki IS broken. Anyway, I’m glad I was of help.

Kenn
LBNLOn 12/13/2007 2:43 PM, JB Segal wrote:

Kenn,
This is fabulous! Thank you so much.
Would you mind me sticking this in to the wiki to fix the broken
information that’s in there?

Everyone: Is there a matrix (simpler than grovelling through all the
perldoc that’s out there) of all the objects you can pull out of a
ticket/stick in to a template/scrip/etc? Have I just not found it in the
wiki yet?

JB

Quoth Kenneth Crocker (KFCrocker@lbl.gov):

JB,

Here is a copy of a “Template” I use. In this template, I am grabbing a Custom Field (named
‘Description’) and printing it in the body of an email:

Subject: Request Titled: “{$Ticket->Subject}” has been Rejected!


TICKET INFORMATION:
Ticket Queue : {$Ticket->QueueObj->Name}
Ticket Number : #{$Ticket->id}
Ticket Subject: {$Ticket->Subject}
Ticket Description:
{
return $Ticket->FirstCustomFieldValue(‘Description’);
}
Ticket Priority is: {$Ticket->Priority}
Ticket Created by: {$Ticket->CreatorObj->Name}
Ticket Created on: {substr($Ticket->Created, 0, 10)}

This “Template” could also serve as an example of how to just
pull different “Ticket” information and put it into an email. Take
particular notice of the blank line between the subject (a header)
line and the body of the template (I like to put in a dashed line, for
effect). RT has default header info and by using the name of the header
line (i.e. “Subject:”) I am essentially overriding that default. However,
RT needs for me to put a blank line between any header line overrides and
the body so it can tell the difference. Otherwise, it won’t work. Hope
this helps.

Kenn
LBNL


The rt-users Archives

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we’ll take
up to 20 percent off the price. This sale won’t last long, so get in touch today.
Email us at sales@bestpractical.com or call us at +1 617 812 0745.

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

No the wiki doesn’t have such a matrix of the RT Objects, or at least I never found one.
There’s bits and pieces.

Hopefully such a matrix would have a list of the Transaction->Type values. That’s what I’m looking for at the moment.
ChristopherFrom: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of JB Segal
Sent: Friday, 14 December 2007 9:43 AM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] CFs in Templates?

Kenn,
This is fabulous! Thank you so much.
Would you mind me sticking this in to the wiki to fix the broken
information that’s in there?

Everyone: Is there a matrix (simpler than grovelling through all the
perldoc that’s out there) of all the objects you can pull out of a
ticket/stick in to a template/scrip/etc? Have I just not found it in the
wiki yet?

JB

Quoth Kenneth Crocker (KFCrocker@lbl.gov):

JB,

  Here is a copy of a "Template" I use. In this template, I am grabbing a Custom Field (named

‘Description’) and printing it in the body of an email:

Subject: Request Titled: “{$Ticket->Subject}” has been Rejected!


TICKET INFORMATION:
Ticket Queue : {$Ticket->QueueObj->Name}
Ticket Number : #{$Ticket->id}
Ticket Subject: {$Ticket->Subject}
Ticket Description:
{
return $Ticket->FirstCustomFieldValue(‘Description’);
}
Ticket Priority is: {$Ticket->Priority}
Ticket Created by: {$Ticket->CreatorObj->Name}
Ticket Created on: {substr($Ticket->Created, 0, 10)}

This “Template” could also serve as an example of how to just
pull different “Ticket” information and put it into an email. Take
particular notice of the blank line between the subject (a header)
line and the body of the template (I like to put in a dashed line, for
effect). RT has default header info and by using the name of the header
line (i.e. “Subject:”) I am essentially overriding that default. However,
RT needs for me to put a blank line between any header line overrides and
the body so it can tell the difference. Otherwise, it won’t work. Hope
this helps.

Kenn
LBNL
The rt-users Archives

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we’ll take
up to 20 percent off the price. This sale won’t last long, so get in touch today.
Email us at sales@bestpractical.com or call us at +1 617 812 0745.

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

Quoth JB Segal (jb@smarterliving.com):

Kenn,
This is fabulous! Thank you so much.
Would you mind me sticking this in to the wiki to fix the broken
information that’s in there?

I tweaked the wiki, mainly noting that what was there doesn’t work, but
also including a bit of the howto.

Further wiki searching lead me to
http://wiki.bestpractical.com/view/AddCustomFieldstoTemplates
and Christopher C. Weis’ helpful addition. I’m almost there. But…

My problem now is…
This works:

{ my $Pvalues = $Ticket->CustomFieldValues(‘Product’);
my $AAvalues = $Ticket->CustomFieldValues(‘Application Area’);
my $OUTPUT;
while ( my $value = $Pvalues->Next ) {
$OUTPUT .= "X-Product: ";
$OUTPUT .= $value->Content;
$OUTPUT .= “\n”;
}
while ( my $value = $AAvalues->Next ) {
$OUTPUT .= "X-Application-Area: ";
$OUTPUT .= $value->Content;
$OUTPUT .= “\n”;
}
$OUTPUT;
}
but is, of course, ugly.

I’m aiming at collapsing this in to a single, extensible loop,
something like:

{ my @CFlist = (‘Product’, ‘Application Area’);
foreach my $CFname (@CFlist) {
my $CFvalues = $Ticket->CustomFieldValues($CFname);
my $OUTPUT;
while ( my $value = $CFvalues->Next ) {
$CFName =~ s/ /-/g;
$OUTPUT .= "X-$CFname: ";
$OUTPUT .= ($value->Content eq ‘’) ? $value->Content : ‘unset’;
$OUTPUT .= “\n”;
}
$OUTPUT;
}
}

but this doesn’t work.

What am I missing? It’s probably REALLY stupid… really, I don’t speak
perl.

Thanks in advance and I hope everyone has a great weekend!
JB

JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com

Quoth JB Segal (jb@smarterliving.com):

{ my @CFlist = (‘Product’, ‘Application Area’);
foreach my $CFname (@CFlist) {
my $CFvalues = $Ticket->CustomFieldValues($CFname);
my $OUTPUT;
while ( my $value = $CFvalues->Next ) {
$CFName =~ s/ /-/g;
$OUTPUT .= "X-$CFname: ";
$OUTPUT .= ($value->Content eq ‘’) ? $value->Content : ‘unset’;
$OUTPUT .= “\n”;
}
$OUTPUT;
}
}

but this doesn’t work.

fixing it so it read
$OUTPUT .= ($value->Content neq ‘’) ? $value->Content : ‘unset’;
doesn’t help, and neither does
$OUTPUT .= $value->Content ? $value->Content : ‘unset’;

I’ve reverted to the non-looping version for the weekend. I look forward
to enlightenment on Monday. :slight_smile:

JB
JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com

Status update: Due to some fine, fine IRC-based help, I’ve got this
working - mostly.

The problems were:
$OUTPUT was being declared and dumped inside the loop, so nothing was
ever being set,
AND Then, at some point, I introduced ‘CFName’… which is not the same
as ‘CFname’… which kept anything from working for quite a while.

So what I have now, that mostly works is:
RT-Attach-Message: yes
{ my @CFlist = (‘Product’, ‘Application Area’, ‘Request Type’, ‘OK to Outsource’, ‘Secondary Status’);
my $OUTPUT;
foreach my $CFname (@CFlist) {
my $CFvalues = $Ticket->CustomFieldValues($CFname);
while ( my $value = $CFvalues->Next ) {
$CFname =~ s/ /-/g;
$OUTPUT .= "X-${CFname}: ";
$OUTPUT .= (($value->Content ne ‘’) ? $value->Content : ‘unset’);
$OUTPUT .= “\n”;
} } $OUTPUT; }

What’s not working about this?

A) Originally I had ‘RT-Attach-Message: yes’ at the bottom of this, with
no blank line between the “$OUTPUT; }” and the “RT-Attach-Message: yes”
and yet a blank line was being generated and the attachments weren’t,
well, attaching.

B) I’m only getthing the 1st 2 CFs - ‘Product’, ‘Application Area’ -
populated. Of the 5, they’re the only ‘Select Multiple’ ones, the others
are all ‘Select One’.

In discussions on IRC, it was suggested that I look at RT/Record.pm and
how FirstCustomFieldValue and CustomFieldValues are generated. As near
as I can tell, FCFV simply calls CFV and returns the 1st value.
This leaves me perplexed as to why I can’t call CFV on a Select One and
have it do the Right Thing™.

If anyone has any further suggestions, I’d love to hear them.

(The next expansion of this whole thing is the automatic inclusion of
headers for all CFs appropriate for every given queue. Suggestions as to
what I want to do there are totally welcome.)

JB

Quoth JB Segal (jb@smarterliving.com):

{ my @CFlist = (‘Product’, ‘Application Area’);
foreach my $CFname (@CFlist) {
my $CFvalues = $Ticket->CustomFieldValues($CFname);
my $OUTPUT;
while ( my $value = $CFvalues->Next ) {
$CFName =~ s/ /-/g;
$OUTPUT .= "X-$CFname: ";
$OUTPUT .= ($value->Content eq ‘’) ? $value->Content : ‘unset’;
$OUTPUT .= “\n”;
}
$OUTPUT;
}
}

but this doesn’t work.
JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com

JB,

"AND Then, at some point, I introduced 'CFName'... which is not the 

same as ‘CFname’… which kept anything from working for quite a while."
That’s funny. I can’t tell you how many times I’ve done that.
I have a question on your CF values. This may seem dumb and I don’t
want to insult you, but does EACH of the CF’s you are trying to set have
(as one of the “defined” values) the value you are trying to set it to?
For example, if you are trying to set CF-1 to “Wierd” and “Wierd” is NOT
one of the values defined, I don’t think it will work. I thought it just
might be something you were overlooking and another set of eyes would help.
The only other thing I can think of is that when I set several CF’s to
a value in a scrip, I make sure the STAGE is “TransactionBatch” and they
all work fine. Hope this helps.

Kenn
LBNLOn 12/18/2007 9:56 AM, JB Segal wrote:

Status update: Due to some fine, fine IRC-based help, I’ve got this
working - mostly.

The problems were:
$OUTPUT was being declared and dumped inside the loop, so nothing was
ever being set,
AND Then, at some point, I introduced ‘CFName’… which is not the same
as ‘CFname’… which kept anything from working for quite a while.

So what I have now, that mostly works is:
RT-Attach-Message: yes
{ my @CFlist = (‘Product’, ‘Application Area’, ‘Request Type’, ‘OK to Outsource’, ‘Secondary Status’);
my $OUTPUT;
foreach my $CFname (@CFlist) {
my $CFvalues = $Ticket->CustomFieldValues($CFname);
while ( my $value = $CFvalues->Next ) {
$CFname =~ s/ /-/g;
$OUTPUT .= "X-${CFname}: ";
$OUTPUT .= (($value->Content ne ‘’) ? $value->Content : ‘unset’);
$OUTPUT .= “\n”;
} } $OUTPUT; }

What’s not working about this?

A) Originally I had ‘RT-Attach-Message: yes’ at the bottom of this, with
no blank line between the “$OUTPUT; }” and the “RT-Attach-Message: yes”
and yet a blank line was being generated and the attachments weren’t,
well, attaching.

B) I’m only getthing the 1st 2 CFs - ‘Product’, ‘Application Area’ -
populated. Of the 5, they’re the only ‘Select Multiple’ ones, the others
are all ‘Select One’.

In discussions on IRC, it was suggested that I look at RT/Record.pm and
how FirstCustomFieldValue and CustomFieldValues are generated. As near
as I can tell, FCFV simply calls CFV and returns the 1st value.
This leaves me perplexed as to why I can’t call CFV on a Select One and
have it do the Right Thing™.

If anyone has any further suggestions, I’d love to hear them.

(The next expansion of this whole thing is the automatic inclusion of
headers for all CFs appropriate for every given queue. Suggestions as to
what I want to do there are totally welcome.)

JB

Quoth JB Segal (jb@smarterliving.com):

{ my @CFlist = (‘Product’, ‘Application Area’);
foreach my $CFname (@CFlist) {
my $CFvalues = $Ticket->CustomFieldValues($CFname);
my $OUTPUT;
while ( my $value = $CFvalues->Next ) {
$CFName =~ s/ /-/g;
$OUTPUT .= "X-$CFname: ";
$OUTPUT .= ($value->Content eq ‘’) ? $value->Content : ‘unset’;
$OUTPUT .= “\n”;
}
$OUTPUT;
}
}

but this doesn’t work.

JB Segal 617-886-5575 www.smartertravel.com
Systems/Network Admin. 465 Medford St. Ste 400 www.bookingbuddy.com
Smarter Travel Media LLC Boston, MA 02129 www.tripmania.com


The rt-users Archives

SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:

If you sign up for a new RT support contract before December 31, we’ll take
up to 20 percent off the price. This sale won’t last long, so get in touch today.
Email us at sales@bestpractical.com or call us at +1 617 812 0745.

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