[rt-users] RE: automatically set due date and priority based on customfield
Roedel, Mark
MarkRoedel at letu.edu
Tue Nov 14 10:40:09 EST 2006
In our case, it's just an "Select one value"-type custom field applied
to tickets in a particular queue.
Looking at the code, the first thing I can see that might trip you up is
in the custom condition, which refers to the custom field by its
internal ID ("13") rather than by its name. If the problem you're
having is just that the scrip doesn't fire, that's probably the first
place I'd look. (You can find the internal ID of your custom field by
looking at the id parameter in the URL while you're editing it in the
configuration screens.)
If that doesn't help, perhaps a bit more detail as to how the scrip is
failing for you would be helpful...
--
Mark Roedel
Senior Programmer / Analyst
LeTourneau University
-----Original Message-----
From: joey [mailto:j0ey at j0ey.de]
Sent: Tuesday, November 14, 2006 8:57 AM
To: RT-Users at lists.bestpractical.com
Cc: Roedel, Mark
Subject: automatically set due date and priority based on customfield
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