[rt-users] problem with trigger

Kenneth Crocker kfcrocker at lbl.gov
Tue Jun 15 15:35:19 EDT 2010


Michael,

Try this:

Name: Set Owner on CF
Condition: User-Defined
Action: User-Defined
Template: Blank
Stage: TransactionBatch

Custom Condition:
#determine if correct CF & value changed

my $trans = $self->TransactionObj;
my $ticket = $self->TicketObj;

if  ($trans->Type eq 'CustomField')
    {my $cf = new RT::CustomField($RT::SystemUser);
        $cf->LoadByName(Queue => $ticket->QueueObj->id,
         Name => "Port Completion");
     return 0 unless $cf->id;
     if  ($trans->Field == $cf->id &&
          $trans->NewValue eq "Ported and Routed")
          {
           return 1;
          }
    }

return 0;

Custom Prep Code:
# set Ticket Owner ID

my $ticket = $self->TicketObj;
my $ownerid = my id

$ticket->SetOwner($ownerid);
return 1;

Custom Cleanup Code:

return 1;

Hope this helps

Kenn
LBNL

On Tue, Jun 15, 2010 at 12:05 PM, Michael W. Lucas <
mwlucas at blackhelicopters.org> wrote:

> Hi,
>
> I'm trying to write a trigger for a particular custom field, as
> described at
> http://wiki.bestpractical.com/view/OnCustomFieldValueChange, and
> apparently I don't understand something.  I'd appreciate any
> enlightenment anyone can offer, pointers to docs I should read, etc.
>
> I have a CustomField called "Port Completion".  When this CustomField
> is set to "Ported and Routed", I want the call assigned to myself.
> This CustomField appears to be Field 15, given that the URL ends in
> "Modify.html?id=15".
>
> I've created a scrip for my test queue with the following settings:
>
> Description: assign owner on port completion
> Condition: user defined
> Action: user defined
> Template: Global template: Transaction
> Stage: TransactionCreate
>
> My custom condition is taken straight from the example.
>
> unless (
>  ( $self->TransactionObj->Type eq "CustomField"
>   &&  $self->TransactionObj->Field == 15 )
>  ||  $self->TransactionObj->Type eq "Create"
>  ) {
>   return 0;
> }
>
> return 0 unless $self->TicketObj->FirstCustomFieldValue('Port Completion')
> =~ /Ported and Routed/i;
>
> 1;
>
> The Custom action preparation code is:
>
> $self->TicketObj->SetOwner('Michael W Lucas');
> return 1;
>
> There is no cleanup code.  This looks like it should be perfectly
> straightforward.
>
> Any suggestions, folks?  Is there any place I can trace what's
> happening in the scrip, or what RT is doing when this is run?
>
> Thanks,
> ==ml
>
> --
> Michael W. Lucas        mwlucas at BlackHelicopters.org
> http://www.MichaelWLucas.com/, http://blather.MichaelWLucas.com/
> New book:  Network Flow Analysis
> pre-order now!  http://www.networkflowanalysis.com/
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20100615/49e26ab1/attachment.htm>


More information about the rt-users mailing list