Question on use of Category in a scrip

To List,

Has anyone used the category of a Custom Field in a scrip? Does 

anyone know how to access that information in a scrip? I need to create
a scrip where I need that information. Thanks.

Kenn
LBNL

To List,

Has anyone used the category of a Custom Field in a scrip? Does 

anyone know how to access that information in a scrip? I need to create
a scrip where I need that information. Thanks.

$TicketObj->FirstCustomFieldValue(‘The CF Name’);

Jesse,

I was thinking that that particular command gave me the Custom Field 

value only. I don’t see where the “category” value for that CF can be
determined from that code.

Kenn
LBNLOn 6/9/2009 9:24 AM, Jesse Vincent wrote:

On Tue, Jun 09, 2009 at 09:21:41AM -0700, Ken Crocker wrote:

To List,

Has anyone used the category of a Custom Field in a scrip? Does 

anyone know how to access that information in a scrip? I need to create
a scrip where I need that information. Thanks.

$TicketObj->FirstCustomFieldValue(‘The CF Name’);

Kenn
LBNL


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

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

Jesse,

I was thinking that that particular command gave me the Custom Field value

only. I don’t see where the “category” value for that CF can be determined from
that code.

Indeed. I misread your question. Category is an attribute of the
CustomFieldValue, itself. Getting at it will require some more work
and will be a bit painful

Jesse,

Painful?? Please explain. I'd love to hear it.

Kenn
LBNLOn 6/9/2009 11:56 AM, Jesse Vincent wrote:

On Tue 9.Jun’09 at 11:26:08 -0700, Ken Crocker wrote:

Jesse,

I was thinking that that particular command gave me the Custom Field value

only. I don’t see where the “category” value for that CF can be determined from
that code.

Indeed. I misread your question. Category is an attribute of the
CustomFieldValue, itself. Getting at it will require some more work
and will be a bit painful

Remi,

HA! you're right. That's a bit convoluted but, what the hey. I 

“gotta do what I gotta do”. This will be helpful in validating CF
entries for certain Queues. Thanks.

Kenn
LBNLOn 6/10/2009 8:12 AM, R�mi wrote:

Hi Ken,

here is the code I use to do what you want (quite painful like Jesse
says …)

my $CustomFieldObj = RT::CustomField->new($[0]->CurrentUser);
$CustomFieldObj->LoadById($field);
my $CFVs = $CustomFieldObj->Values;
while ($CFVs and my $value = $CFVs->Next ) {
if ($value->Name eq $
[0]->FirstCustomFieldValue($field)){
return $value->Category;
}
}

($_[0] is a the Ticket object and $field is the CF id)

R�mi

2009/6/9 Ken Crocker <kfcrocker@lbl.gov mailto:kfcrocker@lbl.gov>

Jesse,


    Painful?? Please explain. I'd love to hear it.

Kenn
LBNL


On 6/9/2009 11:56 AM, Jesse Vincent wrote:
On Tue  9.Jun'09 at 11:26:08 -0700, Ken Crocker wrote:
Jesse,

    I was thinking that that particular command gave me the Custom Field value
only. I don't see where the "category" value for that CF can be determined from
that code.
Indeed. I misread your question.  Category is an attribute of the
CustomFieldValue, itself.   Getting at it will require some more work
and will be a bit painful
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com
<mailto:sales@bestpractical.com>


Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi Ken,
what do you mean by category?

Here is part of a scrip I use on our system (RT 3.8.3) that will print (in the log) the CF name, type and validation pattern. See if that helps.

my $ticket = $self->TicketObj;

my $CustomFields = $ticket->QueueObj->TicketCustomFields();
while (my $CustomField = $CustomFields->Next()) {
my $nam = $CustomField->Name;
my $typ = $CustomField->Type;
my $vad = $CustomField->Pattern;

$RT::Logger->info( ">  CustomField: $nam \n" );
$RT::Logger->info( ">  CustomField: $typ \n" );
$RT::Logger->info( ">  CustomField: $vad \n" );

}

Bye
Cris

Da: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] Per conto di Ken Crocker
Inviato: martedì 9 giugno 2009 20.26
A: Jesse Vincent
Oggetto: Re: [rt-users] Question on use of Category in a scrip

Jesse,

I was thinking that that particular command gave me the Custom Field value only. I don't see where the "category" value for that CF can be determined from that code.

Kenn
LBNLOn 6/9/2009 9:24 AM, Jesse Vincent wrote:

On Tue, Jun 09, 2009 at 09:21:41AM -0700, Ken Crocker wrote:

To List,

Has anyone used the category of a Custom Field in a scrip? Does

anyone know how to access that information in a scrip? I need to create

a scrip where I need that information. Thanks.

$TicketObj->FirstCustomFieldValue(‘The CF Name’);

Kenn

LBNL

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com

Commercial support: sales@bestpractical.commailto:sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.

Buy a copy at http://rtbook.bestpractical.com

Hi Ken,

here is the code I use to do what you want (quite painful like Jesse says
…)

my $CustomFieldObj = RT::CustomField->new($[0]->CurrentUser);
$CustomFieldObj->LoadById($field);
my $CFVs = $CustomFieldObj->Values;
while ($CFVs and my $value = $CFVs->Next ) {
if ($value->Name eq $
[0]->FirstCustomFieldValue($field)){
return $value->Category;
}
}

($_[0] is a the Ticket object and $field is the CF id)

Rémi2009/6/9 Ken Crocker kfcrocker@lbl.gov

Jesse,

Painful?? Please explain. I'd love to hear it.

Kenn
LBNL

On 6/9/2009 11:56 AM, Jesse Vincent wrote:

On Tue 9.Jun’09 at 11:26:08 -0700, Ken Crocker wrote:

Jesse,

I was thinking that that particular command gave me the Custom Field value

only. I don’t see where the “category” value for that CF can be determined from
that code.

Indeed. I misread your question. Category is an attribute of the
CustomFieldValue, itself. Getting at it will require some more work
and will be a bit painful


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

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

It might be good if someone could update the wiki with this code, but
I don’t think I should be the one to do it as I’m not a programmer. :wink:
I think it might be helpful for others trying to answer this question
in the future.
Cassandra Phillips-Sears
Office Manager
Best Practical Solutions, LLC
http://www.bestpractical.comOn Jun 10, 2009, at 11:12 AM 6/10/09, Rémi wrote:

Hi Ken,

here is the code I use to do what you want (quite painful like Jesse
says …)

my $CustomFieldObj = RT::CustomField->new($[0]->CurrentUser);
$CustomFieldObj->LoadById($field);
my $CFVs = $CustomFieldObj->Values;
while ($CFVs and my $value = $CFVs->Next ) {
if ($value->Name eq $
[0]->FirstCustomFieldValue($field)){
return $value->Category;
}
}

($_[0] is a the Ticket object and $field is the CF id)

Rémi

2009/6/9 Ken Crocker kfcrocker@lbl.gov
Jesse,

Painful?? Please explain. I'd love to hear it.

Kenn
LBNL

On 6/9/2009 11:56 AM, Jesse Vincent wrote:

On Tue 9.Jun’09 at 11:26:08 -0700, Ken Crocker wrote:

Jesse,

I was thinking that that particular command gave me the Custom  

Field value
only. I don’t see where the “category” value for that CF can be
determined from
that code.

Indeed. I misread your question. Category is an attribute of the
CustomFieldValue, itself. Getting at it will require some more work
and will be a bit painful


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

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


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

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

I agree that it might be good to have this information in the Wiki. But the
solution I proposed is probably not the better one and could cause some
unwanted load on the system.

Even if we can’t access the “CF Category” directly by the RT API, I 'm sure
we can do it with a simple sql query,
I’m a bit confused with the RT DB schema to do it fast, I will work on it
when I have some time.
If somebody can help me doing this, it will be welcome.2009/6/11 Cassandra Phillips-Sears cassandra@bestpractical.com

It might be good if someone could update the wiki with this code, but I
don’t think I should be the one to do it as I’m not a programmer. :wink: I think
it might be helpful for others trying to answer this question in the future.

Cassandra Phillips-Sears
Office Manager
Best Practical Solutions, LLC
http://www.bestpractical.com

On Jun 10, 2009, at 11:12 AM 6/10/09, Rémi wrote:

Hi Ken,

here is the code I use to do what you want (quite painful like Jesse says
…)

my $CustomFieldObj = RT::CustomField->new($[0]->CurrentUser);
$CustomFieldObj->LoadById($field);
my $CFVs = $CustomFieldObj->Values;
while ($CFVs and my $value = $CFVs->Next ) {
if ($value->Name eq $
[0]->FirstCustomFieldValue($field)){
return $value->Category;
}
}

($_[0] is a the Ticket object and $field is the CF id)

Rémi

2009/6/9 Ken Crocker kfcrocker@lbl.gov

Jesse,

Painful?? Please explain. I'd love to hear it.

Kenn
LBNL

On 6/9/2009 11:56 AM, Jesse Vincent wrote:

On Tue 9.Jun’09 at 11:26:08 -0700, Ken Crocker wrote:

Jesse,

I was thinking that that particular command gave me the Custom Field value

only. I don’t see where the “category” value for that CF can be determined from
that code.

Indeed. I misread your question. Category is an attribute of the
CustomFieldValue, itself. Getting at it will require some more work
and will be a bit painful


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

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


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

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


http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

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