[rt-users] Modification of RT-Extension-SLA

Christian Cuvelier christian.cuvelier at attmes.com
Thu Mar 11 15:33:09 EST 2010


Hi there,

another question about RT-Extension-SLA. First of all i must tell you that I´m
really a starter with Perl. I have to modify the Extension because we need some
kind of "floating" SLA.

When a ticket arrives before 12.00 am it´s necessary to set SLA to next day
23:59:59, if it arrives later than 12.00 am i need to set it two days later
23:59:59.

I used the function SetToMidnight with the due date as Argument. So I´ve tried
to get the difference between these two dates, if it is more than 12 hours than
the ticket was created later than 12 am, if less, earlier than 12 am.

Here´s some code I´ve started with, so maybe you can tell me how I can finish it
??


use strict;
use warnings;

package RT::Action::SLA_SetFloatingDue;
use RT::Date;
use Time::Local;

use base qw(RT::Action::SLA);

=head2 Prepare

Checks if the ticket has service level defined.

=cut

sub Prepare {
    my $self = shift;

    unless ( $self->TicketObj->FirstCustomFieldValue('SLA') ) {
        $RT::Logger->error('SLA::SetDue scrip has been applied to ticket #'
            . $self->TicketObj->id . ' that has no SLA defined');
        return 0;
    }

    return 1;
 }


=head2 Commit

Set the Due date accordingly to SLA.

=cut

sub Commit {

        my $self = shift;

        my $ticket = $self->TicketObj;

        my $due=$ticket->DueObj;

        my $midnight = RT::Date::SetToMidnight($due);
        $midnight = $midnight->Unix;
        $due = $due->Unix;
        my $diff = RT::Date::Diff($due,$midnight);
        $RT::Logger->debug("Midnight" . $midnight);

        # This is only for test reasons, later we have to change it to correct
settings
        return $self->TicketObj->SetDue($due);
}
1;
                 

And this is the error message :

[error]: Scrip Commit 25 died. - Undefined subroutine
 &RT::Action::SLA_SetFloatingDue::Diff called at /opt/rt3/local/plugins/RT-Exten
sion-SLA/lib/RT/Action/SLA_SetFloatingDue.pm line 47.
    
              
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20100311/6d0e56c8/attachment.htm>


More information about the rt-users mailing list