[rt-users] Routing New Requests by Time

Kevin Falcone falcone at bestpractical.com
Thu Jun 3 11:38:15 EDT 2010

On Wed, Jun 02, 2010 at 12:51:00PM -0400, AJ Ferrigno wrote:
> 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20100603/389476eb/attachment.sig>

More information about the rt-users mailing list