Newbie question regarding Custom Fields in Templates

I spent the day in the RT Essentials book and on the Wiki trying to figure out how to create a custom Template that will autoreply. These autoreplies are in response to a request for information in a sales queue. I’ve got everything working except that I can’t seem to get to a custom value I need into the Template.

Basically we have a webform that emails the data to RT. I was able to scrape the email and get the values into the custom fields (using ExtractCustomFieldValues) - one of those values is the email address they want to be contacted at. When I try to reference that within a Template like this:

It returns undef. I know the value is there in the ticket - I can see it on the screen. The field is called Email. So what am I doing wrong? I’ve researched what I could and fought with it all day - I need some help please!

Thanks!

“If there were no God, there would be no Atheists.” - G. K. Chesterson

Bill Weaver
Director of Engineering
Amicus, Inc.
512-531-3463

No, that didn’t work either. In fact, it fails to generate a message at all when I put that in the template so obviously that object isn’t defined inside a template. At least with $Ticket a message generates, I just can’t get to the data I need. I’m doing something wrong in my reference, I just don’t know what it is.----- Original Message -----
From: Michael Lederman mlederman@alvinailey.org
To: Bill Weaver wweaver@amicus.com
Sent: Friday, November 10, 2006 10:22:57 AM GMT-0600 US/Central
Subject: RE: [rt-users] Newbie question regarding Custom Fields in Templates

Try $TicketObj->FirstCustomFieldValue() instead. Its what I’ve had success with in my scrips.

Mike

From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Bill Weaver
Sent: Thursday, November 09, 2006 10:10 PM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Newbie question regarding Custom Fields in Templates

I spent the day in the RT Essentials book and on the Wiki trying to figure out how to create a custom Template that will autoreply. These autoreplies are in response to a request for information in a sales queue. I’ve got everything working except that I can’t seem to get to a custom value I need into the Template.

Basically we have a webform that emails the data to RT. I was able to scrape the email and get the values into the custom fields (using ExtractCustomFieldValues) - one of those values is the email address they want to be contacted at. When I try to reference that within a Template like this:

To: {$Ticket->FirstCustomFieldValue(‘Email’);}

It returns undef. I know the value is there in the ticket - I can see it on the screen. The field is called Email. So what am I doing wrong? I’ve researched what I could and fought with it all day - I need some help please!

Thanks!

“If there were no God, there would be no Atheists.” - G. K. Chesterson

Bill Weaver
Director of Engineering
Amicus, Inc.
512-531-3463

“If there were no God, there would be no Atheists.” - G. K. Chesterson

Bill Weaver
Director of Engineering
Amicus, Inc.
512-531-3463

This a copy and paste from what works for me in my templates:

{$Ticket->FirstCustomFieldValue(‘Application’)}

[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Bill
WeaverSent: Friday, November 10, 2006 11:37 AM
To: Michael Lederman; rt-users
Subject: Re: [rt-users] Newbie question regarding Custom Fields in
Templates

No, that didn’t work either. In fact, it fails to generate a message at
all when I put that in the template so obviously that object isn’t
defined inside a template. At least with $Ticket a message generates, I
just can’t get to the data I need. I’m doing something wrong in my
reference, I just don’t know what it is.

Bill,

We had something similar to that. What we discovered was that we were 

trying to get more than 1 item per return. I believe the RT code allows
only 1 retrieval of 1 data item per return code. when we broke up the
returns to getting 1 item at a time, we were successful. I did not see
all of your code so I don’t know that this is your problem, but our
retrieval of data in Templates works now. Hope this helps.

Kenn
LBNL

Bill Weaver wrote:

Two things make me question whether this is the issue I’m seeing; first, this is a single field with a single value and second, I’m using FirstCustomFieldValue which it is my understanding returns one and only one value regardless (i.e. the first). Am I mistaken?

I do appreciate the help and am trying any and all suggestions as I’ve been beating my head against this for a day and a half now ;o)!----- Original Message -----
From: Kenneth Crocker KFCrocker@lbl.gov
To: Bill Weaver wweaver@amicus.com
Cc: Michael Lederman mlederman@alvinailey.org, rt-users rt-users@lists.bestpractical.com
Sent: Friday, November 10, 2006 11:58:09 AM GMT-0600 US/Central
Subject: Re: [rt-users] Newbie question regarding Custom Fields in Templates

Bill,

We had something similar to that. What we discovered was that we were
trying to get more than 1 item per return. I believe the RT code allows
only 1 retrieval of 1 data item per return code. when we broke up the
returns to getting 1 item at a time, we were successful. I did not see
all of your code so I don’t know that this is your problem, but our
retrieval of data in Templates works now. Hope this helps.

Kenn
LBNL

When I try to reference that within a
Template like this:

To: {$Ticket->FirstCustomFieldValue(‘Email’);}

It returns undef.

You want to do something like this instead:

To: {
my $email;
my $val = $Ticket->CustomFieldValues('Email')->First();

if ($val) {
    $email = $val->Content();
}

# no value for 'Email' CF
else {
    $email = 'root@localhost';
}

$email;
}

See RT/Ticket_Overlay.pm and RT/Record.pm .

Garry T. Williams — 678-370-2438

Thanks for the reply. I tried your suggestion below but the address
it ends up with is the “root@localhost” value so it still isn’t
getting it from the custom field.

So we have established that the ticket does not have the custom field
value when accessed from some queue by some user.

It sounds like you need to add permissions for this custom field in
some queue.

Have a look at Configuration->Queues->Ticket Custom Fields

Garry T. Williams — 678-370-2438

I show this field applying to the “Sales” queue which is where the
Scrip and Template also are. Under Group rights, I had it set where
“Everyone” could see it and “Sales” could modify it. I’ve since
added seeing to the Privleged and Unprivleged users. Under User
Rights there was nothing defined. I’ve since added “root” giving
them the ability to see as well.

After those changes I tried again - still same (no) result!

I’m out of ideas. I still say you have to enable the particular
custom field for the particular queue.

Have a look at Configuration->Queues->Ticket Custom Fields

Garry T. Williams — 678-370-2438