Set priority by custom field scrip not working

Hi guys,

Could you please assist, I’ve been trying to create a scrip which sets the ticket’s priority according to a custom field but its not working.

The custom field is called Severity and its ID is 77.

I used the following guidelines and the scrip compiled without any issues:

I’m using RT version 4.4.3 running on Centos 6 and the following is my scrip:

Condition and Action are set to “User defined” and a blank template is being applied.

Custom condition:

if (($self->TransactionObj->Type eq “CustomField”) and
($self->TransactionObj->Field eq “77”)) {
} else {

Custom action preparation code:

my $ticket = $self->TicketObj;
my $CFName = ‘Severity’;
my $QueueObj = $self->TicketObj->QueueObj;
my $CFObj = RT::CustomField->new ($QueueObj->CurrentUser);
$CFObj->LoadByNameAndQueue(Name=>$CFName, Queue=>$QueueObj->id);
unless ($CFObj->id) {
$RT::Logger->warning ("$CFName doesn’t exist in Queue " .
return undef;

Custom action commit code:

my $severityvalue = $self->TicketObj->FirstCustomFieldValue($CFObj->id);
if ($severityvalue eq ‘C.E.M’) {
} elsif ($severityvalue eq ‘Severity 1’) {
} elsif ($severityvalue eq ‘Severity 2’) {
} elsif ($severityvalue eq ‘Severity 3’) {
} else {

What behavior do you see when his scrip runs? Do you see any output in your logs? It could be worth adding some logging to ensure that you are hitting the code that you expect to be hitting.

Hi craig

Thanks for the response. Unfortunately I do not see any particular behaviour when the scrip runs. I’ve checked the logs and I see nothing as well.

Do you see any issues in my code though?


I would expect you to see an error in the logs like this:

Commit failed: Global symbol "$CFObj" requires explicit package name (did you forget to declare "my $CFObj"?)

In your Action commit code you use the variable $CFObj but it is not defined in that scope.

Also your action preparation code should return true at the end of that block or else the commit code will not run.

There is a lot of extra complexity added to this though that can make it confusing, if I were to put my two cents in I would consider doing it like this:

Custom Condition Code:

if ($self->TransactionObj->Type eq "CustomField" and
$self->TransactionObj->Field eq "53") {
    return 1;
return 0;

Action Prep Code:

# No need to check if the custom field is applied to this Queue because we
# know the transaction 'Field' value is for the Severity CF.
return 1;

Custom Action Code:

my $severityvalue = $self->TicketObj->FirstCustomFieldValue('Severity');

my %SeverityToPriority = (
    'C.E.M'      => { Priority => 1, FinalPriority => 2 },
    'Severity 1' => { Priority => 10, FinalPriority => 11 },
    'Severity 2' => { Priority => 20, FinalPriority => 21 },
    'Severity 3' => { Priority => 30, FinalPriority => 31 },

if ( $SeverityToPriority{$severityvalue} ) {
    my $values = $SeverityToPriority{$severityvalue};
    my ($ret, $msg) = $self->TicketObj->SetPriority($values->{'Priority'});
    RT::Logger->error($msg) unless $ret;

    ($ret, $msg) = $self->TicketObj->SetFinalPriority($values->{'FinalPriority'});
    RT::Logger->error($msg) unless $ret;

return 1;