Getting customfield value for a ticket

Hi.

We have a custom field named “Customer” that we set for our tickets. I am trying to modify this report to summarize time worked per customer during the given time period: TimeWorkedReport - Request Tracker Wiki

The problem I have is to get the custom field value for a ticket.

I have a Ticket “Object” that is created by
my $t = new RT::Ticket($session{‘CurrentUser’});
$t->Load($tr->ObjectId);

After that I want to get the Custom Field value for this ticket. I can see the data in the ObjectCustomFieldValues table, but I do not know how to get the information I want.
I have the ticket id in $t->id and the CustomField id is 19.
I have tried using the different functions available in the RT perl modules, but have been unable to get it right.
I know very little perl, so I have been working at a trial and error basis.

Do you have any tips for me on how to get it to work?

Best Regards,
Johan Sjöberg

Johan Sj�berg wrote:

Hi.

We have a custom field named �Customer� that we set for our tickets. I
am trying to modify this report to summarize time worked per customer
during the given time period:
TimeWorkedReport - Request Tracker Wiki

The problem I have is to get the custom field value for a ticket.

I have a Ticket �Object� that is created by

my $t = new RT::Ticket($session{‘CurrentUser’});

$t->Load($tr->ObjectId);

After that I want to get the Custom Field value for this ticket. I can
see the data in the ObjectCustomFieldValues table, but I do not know
how to get the information I want.

I have the ticket id in $t->id and the CustomField id is 19.

I have tried using the different functions available in the RT perl
modules, but have been unable to get it right.

I know very little perl, so I have been working at a trial and error
basis.

Do you have any tips for me on how to get it to work?

Best Regards,

Johan Sj�berg


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

Use $t->Content if this custom field only stores one value.

Greetings,

Wolfram

Johan Sjöberg wrote:

Hi.

We have a custom field named “Customer” that we set for our tickets. I
am trying to modify this report to summarize time worked per customer
during the given time period:
TimeWorkedReport - Request Tracker Wiki

The problem I have is to get the custom field value for a ticket.

I have a Ticket “Object” that is created by

my $t = new RT::Ticket($session{‘CurrentUser’});

$t->Load($tr->ObjectId);

After that I want to get the Custom Field value for this ticket. I can
see the data in the ObjectCustomFieldValues table, but I do not know
how to get the information I want.

I have the ticket id in $t->id and the CustomField id is 19.

I have tried using the different functions available in the RT perl
modules, but have been unable to get it right.

I know very little perl, so I have been working at a trial and error
basis.

Do you have any tips for me on how to get it to work?

Best Regards,

Johan Sjöberg


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

Use $t->Content if this custom field only stores one value.

Greetings,

Wolfram

Hi.

Does that work when $t is a ticket? Won’t that just return the content of the ticket? If there even is a Content “property” for the ticket.
BTW, I am using RT 3.8.2 if that matters.

/Johan

We have a custom field named “Customer” that we set for our tickets. I am trying to modify
this report to summarize time worked per customer during the given time period:
[1]TimeWorkedReport - Request Tracker Wiki

The problem I have is to get the custom field value for a ticket.

I have a Ticket “Object” that is created by

my $t = new RT::Ticket($session{‘CurrentUser’});

  $t->Load($tr->ObjectId);

After that I want to get the Custom Field value for this ticket. I can see the data in the
ObjectCustomFieldValues table, but I do not know how to get the information I want.

I have the ticket id in $t->id and the CustomField id is 19.

I have tried using the different functions available in the RT perl modules, but have been
unable to get it right.

I know very little perl, so I have been working at a trial and error basis.

Do you have any tips for me on how to get it to work?

All of the methods you might want for this are defined in RT::Record
and you can read their documentation with
perldoc /opt/rt3/lib/RT/Record.pm

Try searching for CustomFieldValue

-kevin

We have a custom field named “Customer” that we set for our tickets. I am trying to modify
this report to summarize time worked per customer during the given time period:
[1]TimeWorkedReport - Request Tracker Wiki

The problem I have is to get the custom field value for a ticket.

I have a Ticket “Object” that is created by

my $t = new RT::Ticket($session{‘CurrentUser’});

  $t->Load($tr->ObjectId);

After that I want to get the Custom Field value for this ticket. I can see the data in the
ObjectCustomFieldValues table, but I do not know how to get the information I want.

I have the ticket id in $t->id and the CustomField id is 19.

I have tried using the different functions available in the RT perl modules, but have been
unable to get it right.

I know very little perl, so I have been working at a trial and error basis.

Do you have any tips for me on how to get it to work?

All of the methods you might want for this are defined in RT::Record
and you can read their documentation with
perldoc /opt/rt3/lib/RT/Record.pm

Try searching for CustomFieldValue

-kevin

Thanks for your reply. However, I cannot get perldoc to work, when I run perldoc /opt/rt3/lib/RT/Record.pm I get
No documentation found for “/opt/rt3/lib/RT/Record.pm”.
I have verified that Record.pm is in the specified directory. Could this be because my RT is installed using the RPM packages from http://www.tlviewer.org/rt3/rt-3.8.2/ and that the docs are missing?

/Johan

We have a custom field named “Customer” that we set for our tickets. I am trying to modify
this report to summarize time worked per customer during the given time period:
[1]TimeWorkedReport - Request Tracker Wiki

The problem I have is to get the custom field value for a ticket.

I have a Ticket “Object” that is created by

my $t = new RT::Ticket($session{‘CurrentUser’});

  $t->Load($tr->ObjectId);

After that I want to get the Custom Field value for this ticket. I can see the data in the
ObjectCustomFieldValues table, but I do not know how to get the information I want.

I have the ticket id in $t->id and the CustomField id is 19.

I have tried using the different functions available in the RT perl modules, but have been
unable to get it right.

I know very little perl, so I have been working at a trial and error basis.

Do you have any tips for me on how to get it to work?

All of the methods you might want for this are defined in RT::Record
and you can read their documentation with
perldoc /opt/rt3/lib/RT/Record.pm

Try searching for CustomFieldValue

-kevin

Thanks for your reply. However, I cannot get perldoc to work, when I run perldoc /opt/rt3/lib/RT/Record.pm I get
No documentation found for “/opt/rt3/lib/RT/Record.pm”.
I have verified that Record.pm is in the specified directory. Could this be because my RT is installed using the RPM packages from http://www.tlviewer.org/rt3/rt-3.8.2/ and that the docs are missing?

/Johan

Sorry, I did only check that the path to the pm files was correct. I do not have any Record.pm anywhere on the server…

/Johan

We have a custom field named “Customer” that we set for our tickets. I am trying to modify
this report to summarize time worked per customer during the given time period:
[1]TimeWorkedReport - Request Tracker Wiki

The problem I have is to get the custom field value for a ticket.

I have a Ticket “Object” that is created by

my $t = new RT::Ticket($session{‘CurrentUser’});

  $t->Load($tr->ObjectId);

After that I want to get the Custom Field value for this ticket. I can see the data in the
ObjectCustomFieldValues table, but I do not know how to get the information I want.

I have the ticket id in $t->id and the CustomField id is 19.

I have tried using the different functions available in the RT perl modules, but have been
unable to get it right.

I know very little perl, so I have been working at a trial and error basis.

Do you have any tips for me on how to get it to work?

All of the methods you might want for this are defined in RT::Record
and you can read their documentation with
perldoc /opt/rt3/lib/RT/Record.pm

Try searching for CustomFieldValue

-kevin

Thanks for your reply. However, I cannot get perldoc to work, when I run perldoc /opt/rt3/lib/RT/Record.pm I get
No documentation found for “/opt/rt3/lib/RT/Record.pm”.
I have verified that Record.pm is in the specified directory. Could this be because my RT is installed using the RPM packages from http://www.tlviewer.org/rt3/rt-3.8.2/ and that the docs are missing?

/Johan

Sorry, I did only check that the path to the pm files was correct. I do not have any Record.pm anywhere on the server…

/Johan

I solved it. Perldoc was an easier way to understand things than reading the code.

This is how I did it, if anyone is interested:
—snip

what customer is this?

my $c = “”;
my $cfs = $t->CustomFieldValues;
while (my $cf = $cfs->Next) {
if ($cf->CustomField == 19) {
$c = $cf->Content;
}
}
—snip

/Johan