[Rt-devel] Using Business::Hours to set the CF Response Time

Anders Ekstrand Anders.Ekstrand at drutt.com
Tue Aug 28 10:35:50 EDT 2007


Hi all,

I was up to using a scrip to automatically set my custom field "Response
Time" to a proper value, when sending the first response to a customer
in a ticket.

I found nothing on the RT Wiki that I could use, so I installed
Business::Hours and Set::IntSpan and tried the following scrip on my RT
3.6.5RC2 installation:



use Business::Hours;

my $BusinessHours = Business::Hours->new();    
my $Ticket = $self->TicketObj;
my $cfResponseTime = new RT::CustomField( $RT::SystemUser );
my $responseTime = $Ticket->FirstCustomFieldValue( 'Response Time' );

if ( !$responseTime ) {
  
  my $createdTime = $Ticket->CreatedObj->Unix;
  my $responseTime = $BusinessHours->between( $createdTime, time() );

  $cfResponseTime->LoadByNameAndQueue ( Name=>'Response Time', Queue=>0
);
  $Ticket->AddCustomFieldValue( Field => $cfResponseTime, Value =>
$responseTime );
}

return(1);



Unfortunately, the "between" method only returns -1 for me...

Anybody that has a hint regarding what I could have missed here?


Best Regards - Anders Ekstrand


More information about the Rt-devel mailing list