Routing New Requests by Time

Hello,

I’m on RT 3.8.8. I have a need to route newly created requests for a
specific queue to a certain owner depending on time of day. I’ve
created a custom scrip that seems like it should work, but it is
hanging on the “date” call. The log tells me: Can’t locate object
method “date” via package “Class::Date” (perhaps you forgot to load
"Class::Date"?

My scrip code is below:

my $createddate = Class::date::date $self->TicketObj->Created;
if ($self->TicketObj->Created->hour >= 17)
{$self->TicketObj->SetOwner(‘user1’);}
elsif ($createddate->hour >= 15) {$self->TicketObj->SetOwner(‘user2’);}
elsif ($createddate->hour >= 13) {$self->TicketObj->SetOwner(‘user3’);}
elsif ($createddate->hour >= 11) {$self->TicketObj->SetOwner(‘user4’);}
elsif ($$createddate->hour >= 9) {$self->TicketObj->SetOwner(‘user5’);}

I also tried to call $self->TicketObj->Created->hour, but it seems the
"Created" property doesn’t return a true Perl datetime object? So I
decided to try it this way.

First of all - is this the best way to handle something like this?
Second, I’m using the web interface to paste this code into the
"Custom action preparation code:" section. How do I include a Perl
"use" directive? Do I need to make this scrip an actual perl file on
the server somewhere to do this? (Where would that be?)

Thanks in advance,
AJ

Hello,

I’m on RT 3.8.8. I have a need to route newly created requests for a
specific queue to a certain owner depending on time of day. I’ve
created a custom scrip that seems like it should work, but it is
hanging on the “date” call. The log tells me: Can’t locate object
method “date” via package “Class::Date” (perhaps you forgot to load
“Class::Date”?

My scrip code is below:

my $createddate = Class::date::date $self->TicketObj->Created;
if ($self->TicketObj->Created->hour >= 17)
{$self->TicketObj->SetOwner(‘user1’);}
elsif ($createddate->hour >= 15) {$self->TicketObj->SetOwner(‘user2’);}
elsif ($createddate->hour >= 13) {$self->TicketObj->SetOwner(‘user3’);}
elsif ($createddate->hour >= 11) {$self->TicketObj->SetOwner(‘user4’);}
elsif ($$createddate->hour >= 9) {$self->TicketObj->SetOwner(‘user5’);}

I also tried to call $self->TicketObj->Created->hour, but it seems the
“Created” property doesn’t return a true Perl datetime object? So I
decided to try it this way.

First of all - is this the best way to handle something like this?
Second, I’m using the web interface to paste this code into the
“Custom action preparation code:” section. How do I include a Perl
“use” directive? Do I need to make this scrip an actual perl file on
the server somewhere to do this? (Where would that be?)

You need to just add use Class::Date; above your code like you would
in a normal perl module

You could do what you want with RT::Date and the CreatedObj, but if
you’re more familiar with Class::Date use it. Be careful what
timezone RT thinks Created is in vs Class::Date.

-kevin