[rt-users] automatically set due date and priority based on customfield

joey j0ey at j0ey.de
Tue Nov 14 09:56:55 EST 2006


Hey there,

i found this Scrip (originally posted by Mark Roedel) but can't get it
to work. How do i create a corresponding "CustomField" for this?!

greets,
joey

--------------------------------
Custom condition:
if (($self->TransactionObj->Type eq "CustomField") and
($self->TransactionObj->Field eq "13")) {
return(1);
} else {
return(undef);
}



Custom action cleanup:
my $ticket = $self->TicketObj;
my $CFName = 'Urgency';
my $QueueObj = $self->TicketObj->QueueObj;
my $CFObj = RT::CustomField->new ($QueueObj->CurrentUser);
my $duedate = RT::Date->new($RT::SystemUser);
my $bus_hours_duetime = time;

use Business::Hours;
my $hours = Business::Hours->new();
my $now = time;

$CFObj->LoadByNameAndQueue(Name=>$CFName, Queue=>$QueueObj->id);
unless ($CFObj->id) {
$RT::Logger->warning ("$CFName doesn't exist in Queue " .
$QueueObj->Name);
return undef;
}

my $urgencyvalue = $self->TicketObj->FirstCustomFieldValue($CFObj->id);
if ($urgencyvalue eq 'Emergency') {
$self->TicketObj->SetPriority('100');
$self->TicketObj->SetFinalPriority('100');
$bus_hours_duetime = $hours->add_seconds ($now, 14400);
$duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
$self->TicketObj->SetDue($duedate->ISO);
} elsif ($urgencyvalue eq 'Urgent') {
$self->TicketObj->SetPriority('90');
$self->TicketObj->SetFinalPriority('99');
$bus_hours_duetime = $hours->add_seconds ($now, 32400);
$duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
$self->TicketObj->SetDue($duedate->ISO);
} elsif ($urgencyvalue eq 'Time-Sensitive') {
$self->TicketObj->SetPriority('89');
$self->TicketObj->SetFinalPriority('89');
$bus_hours_duetime = $hours->add_seconds ($now, 97200);
$duedate->Set(Format=>'unix', Value=>$bus_hours_duetime);
$self->TicketObj->SetDue($duedate->ISO);
} elsif ($urgencyvalue eq 'High') {
$self->TicketObj->SetPriority('75');
$self->TicketObj->SetFinalPriority('88');
$duedate->Set(Format=>'unknown', Value=>'15 days');
$self->TicketObj->SetDue($duedate->ISO);
} elsif ($urgencyvalue eq 'Medium') {
$self->TicketObj->SetPriority('50');
$self->TicketObj->SetFinalPriority('74');
$duedate->Set(Format=>'unknown', Value=>'3 months');
$self->TicketObj->SetDue($duedate->ISO);
} elsif ($urgencyvalue eq 'Low') {
$self->TicketObj->SetPriority('25');
$self->TicketObj->SetFinalPriority('49');
$duedate->Set(Format=>'unknown', Value=>'6 months');
$self->TicketObj->SetDue($duedate->ISO);
} elsif ($urgencyvalue eq 'Very Low') {
$self->TicketObj->SetPriority('1');
$self->TicketObj->SetFinalPriority('24');
$duedate->Set(Format=>'unknown', Value=>'1 year');
$self->TicketObj->SetDue($duedate->ISO);
} else {
}
return(1);



More information about the rt-users mailing list