[rt-users] Using custom conditions with custom fields

Todd Chapman todd at chaka.net
Fri Dec 22 17:56:25 EST 2006


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