[rt-users] Scrip to automatically set Owner based on a Custom Field

Ken Crocker kfcrocker at lbl.gov
Fri Oct 30 11:56:21 EDT 2009


Jrummel,

We do this for our queue that reviews requests. Based on the Org code, 
we set the owner for the person best suited to evaluate tickets for that 
organization. This is our code:

#----------------------------------------------------------------------------
# Custom action Preparation Code:
#----------------------------------------------------------------------------
#
# set new ticket owner id value
#
#    42 - Frank
#   148 - Bob
#  5125 - Sally
#  9324 - Roberta
# 73886 - Ted
#

my %orgs = qw(
           Budget-Direct   148
           Budget-Indirect 148
           Controller-AP   5125
           Controller-AR   73886
           Controller-GA   148
           Controller-PR   42
           Facilities      42
           Field OPS       42
           OCFO-Other      42
           Procurement     9324
           Property        9324
           SPO             73886
           Travel          5125
           Other           42
          );

my $cf = new RT::CustomField($RT::SystemUser);
$cf->LoadByName(Queue => $ticket->QueueObj->id,Name => "CFO-Org");
return 0 unless $cf->id;
my $cfvalue = $ticket->FirstCustomFieldValue('CFO-Org'); 
my $ownerid = $orgs{$cfvalue};

# set Ticket Due date & Owner ID

$ticket->SetOwner($ownerid);

return 1;
#----------------------------------------------------------------------------
# Custom action Cleanup Code:
#----------------------------------------------------------------------------

return 1;

I hope this helps.

Kenn
LBNL

On 10/29/2009 4:50 PM, jrummel wrote:
> Hi everyone,
>
> I have a select-one Custom Field called "Product" with 5 products in it. 
> Based on what product is selected (on create), I would like a specific user
> to be set as the Owner (ex: ticket is created with "Product A" selected, so
> John Smith works on Product A, thus should automatically be the Owner). 
> Does anyone know the what my Custom Action would look like to accomplish
> this?
>
> Thanks!
>   



More information about the rt-users mailing list