<p dir="ltr">Hi Matt,</p>
<p dir="ltr">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.</p>
<p dir="ltr">#in custom action preparation code</p>
<p dir="ltr"> </p>
<p dir="ltr">if ($self->TransactionObj->Type eq 'Create' &&</p>
<p dir="ltr">$self->TicketObj->FirstCustomFieldValue(‘YOUR CUSTOM FIELD NAME') eq ‘YOUR CUSTOM FIELD VALUE’){</p>
<p dir="ltr">return 1;}</p>
<p dir="ltr"> </p>
<p dir="ltr">elsif ($self->TransactionObj->Type eq 'Create' &&</p>
<p dir="ltr">$self->TicketObj->FirstCustomFieldValue(‘YOUR CUSTOM FIELD NAME’) eq ‘YOUR CUSTOM FIELD VALUE’){</p>
<p dir="ltr">return 1;}</p>
<p dir="ltr">else{</p>
<p dir="ltr">return 0;}</p>
<p dir="ltr"> </p>
<p dir="ltr">#in custom action commit code:<br></p>
<p dir="ltr">$self->TicketObj->SetOwner(‘JOHN DOE’);</p>
<p dir="ltr">return 1;</p>
<p dir="ltr">Thanks,<br>
Jordan</p>
<div class="gmail_quote">On 10 Feb 2016 15:46, "Matt Zagrabelny" <<a href="mailto:mzagrabe@d.umn.edu">mzagrabe@d.umn.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey Jordan,<br>
<br>
On Wed, Feb 10, 2016 at 4:56 AM, Jordan Taylor via rt-users<br>
<<a href="mailto:rt-users@lists.bestpractical.com">rt-users@lists.bestpractical.com</a>> wrote:<br>
><br>
>> Any help here means alot! Im on the latest version of RT.<br>
>><br>
>> 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.<br>
>><br>
>>  The example script that I have is as follows however it doesn’t work? ;<br>
>><br>
>><br>
>><br>
>> #----------------------------------------------------------------------------<br>
>> # Custom action Preparation Code:<br>
>> #----------------------------------------------------------------------------<br>
>> #<br>
>> # set new ticket owner id value<br>
>> #<br>
>> # 42 - Frank<br>
>> # 148 - Bob<br>
>> # 5125 - Sally<br>
>> # 9324 - Roberta<br>
>> # 73886 - Ted<br>
>> #<br>
>><br>
>> my %orgs = qw(<br>
>> Budget-Direct 148<br>
>> Budget-Indirect 148<br>
>> Controller-AP 5125<br>
>> Controller-AR 73886<br>
>> Controller-GA 148<br>
>> Controller-PR 42<br>
>> Facilities 42<br>
>> Field OPS 42<br>
>> OCFO-Other 42<br>
>> Procurement 9324<br>
>> Property 9324<br>
>> SPO 73886<br>
>> Travel 5125<br>
>> Other 42<br>
>> );<br>
>><br>
>> my $cf = new RT::CustomField($RT::SystemUser);<br>
>> $cf->LoadByName(Queue => $ticket->QueueObj->id,Name => "CFO-Org");<br>
>> return 0 unless $cf->id;<br>
>> my $cfvalue = $ticket->FirstCustomFieldValue('CFO-Org');<br>
<br>
The code looks sensible. Try adding some logging to see what is going on:<br>
<br>
RT->Logger->error($cfvalue);<br>
<br>
>> my $ownerid = $orgs{$cfvalue};<br>
<br>
RT->Logger->error($ownerid);<br>
<br>
>> # set Ticket Due date & Owner ID<br>
>><br>
>> $ticket->SetOwner($ownerid);<br>
>><br>
>> return 1;<br>
<br>
Cheers,<br>
<br>
-m<br>
</blockquote></div>