Hi all,
Any help here means alot! Im on the latest version of RT.
What I want to do is, I want the script to automatically set the owner
based on the custom field which there are a few users that need made owner
of certain values.
The example script that I have is as follows however it doesn’t work? ;
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;
Any help would mean a great deal,
Many Thanks,
Jordan
Hey Jordan,
Any help here means alot! Im on the latest version of RT.
What I want to do is, I want the script to automatically set the owner based on the custom field which there are a few users that need made owner of certain values.
The example script that I have is as follows however it doesn’t work? ;
#----------------------------------------------------------------------------
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’);
The code looks sensible. Try adding some logging to see what is going on:
RT->Logger->error($cfvalue);
my $ownerid = $orgs{$cfvalue};
RT->Logger->error($ownerid);
set Ticket Due date & Owner ID
$ticket->SetOwner($ownerid);
return 1;
Cheers,
-m
Hi Matt,
Thanks for the reply i got it sorted with a different script which i have
done 1 per owner… See bellow script, hope it helps others that are
looking to do the same kind of script.
#in custom action preparation code
if ($self->TransactionObj->Type eq ‘Create’ &&
$self->TicketObj->FirstCustomFieldValue(‘YOUR CUSTOM FIELD NAME’) eq ‘YOUR
CUSTOM FIELD VALUE’){
return 1;}
elsif ($self->TransactionObj->Type eq ‘Create’ &&
$self->TicketObj->FirstCustomFieldValue(‘YOUR CUSTOM FIELD NAME’) eq ‘YOUR
CUSTOM FIELD VALUE’){
return 1;}
else{
return 0;}
#in custom action commit code:
$self->TicketObj->SetOwner(‘JOHN DOE’);
return 1;
Thanks,
JordanOn 10 Feb 2016 15:46, “Matt Zagrabelny” mzagrabe@d.umn.edu wrote:
Hey Jordan,
On Wed, Feb 10, 2016 at 4:56 AM, Jordan Taylor via rt-users rt-users@lists.bestpractical.com wrote:
Any help here means alot! Im on the latest version of RT.
What I want to do is, I want the script to automatically set the owner
based on the custom field which there are a few users that need made owner
of certain values.
The example script that I have is as follows however it doesn’t work? ;
#----------------------------------------------------------------------------
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’);
The code looks sensible. Try adding some logging to see what is going on:
RT->Logger->error($cfvalue);
my $ownerid = $orgs{$cfvalue};
RT->Logger->error($ownerid);
set Ticket Due date & Owner ID
$ticket->SetOwner($ownerid);
return 1;
Cheers,
-m