[rt-users] Using custom conditions with custom fields

Tim Wilson twilson at buffalo.k12.mn.us
Fri Dec 22 21:16:08 EST 2006


Todd (and others),

Thanks for the help. That makes sense to me except for one thing. I'm
not sure where the $my_id comes from. More precisely, I don't see how
comparing $self->TransactionObj->Field to $my_id works in this case. I
realize this isn't a perl tutorial list, but I'm puzzled.

-Tim

-- 
Tim Wilson, Director of Technology
Buffalo-Hanover-Montrose Schools
214 1st Ave NE   Buffalo, MN  55313
ph: 763.682.8740  fax: 763.682.8743  http://www.buffalo.k12.mn.us




>>> Todd Chapman <todd at chaka.net> 12/22/06 4:56 PM >>>
On Fri, Dec 22, 2006 at 01:31:09PM -0600, Tim Wilson wrote:
> Hi all,
> 
> I have what would seem to be a fairly typical situation here. I've got
> a certain queue with two custom fields for each ticket contained
there.
> Let's call the custom fields "Foo" and "Bar." I would like to trigger
a
> scrip when the value of the "Foo" custom field is set to "Baz." I've
got
> the following custom condition for my scrip (adapted from the wiki):
> 
> if ( ($self->TransactionObj->Type eq "CustomField" ||
>       $self->TransactionObj->Type eq "Create" ) &&
>       ($self->TicketObj->FirstCustomFieldValue('Foo') =~ /Baz/i) ) {
>     return 1;
> } 
> return 0;
> 
> This doesn't quite work because it also gets triggered when the "Bar"
> custom field is modified. I only want this to run when "Foo" is set to
> "Baz" regardless of the value of "Bar" and whether  it was changed.
> 
> It would seem that I need a way to have the scrip ignore changes to
> custom fields other than "Foo." Is this possible?
> 

$self->TransactionObj->Field has the Id of the custom
field being changed.

So you would have:


unless ( 
  ( $self->TransactionObj->Type eq "CustomField"
    &&  $self->TransactionObj->Field == $my_id )
  ||  $self->TransactionObj->Type eq "Create"
  ) {
    return 0;
}

return 0 unless $self->TicketObj->FirstCustomFieldValue('Foo') =~
/Baz/i;

1;




More information about the rt-users mailing list