1 package RT::Condition::CustomFieldTransaction;
2 use base 'RT::Condition';
7 RT::Condition::CustomFieldTransaction
11 Returns true if a transaction changed the value of a custom field. Unlike
12 CustomFieldChange, this condition doesn't care what the value was, only that
21 Only return true if the transaction changed a custom field with this name.
22 If empty, returns true for any CustomField-type transaction.
24 =item include_create (boolean) - Also return true for Create-type transactions.
25 If 'field' is specified, return true if that field is non-empty in the newly
32 If the transaction has changed the value of a custom field.
36 Probably interacts badly with multiple custom fields with the same name.
42 my $trans = $self->TransactionObj;
43 my $scrip = $self->ScripObj;
44 my %Rules = $self->Rules;
45 my ($field, $include_create) = @Rules{'field', 'include_create'};
47 if ( $include_create and $trans->Type eq 'Create' ) {
48 return 1 if !defined($field);
49 return 1 if defined($trans->TicketObj->FirstCustomFieldValue($field));
51 if ($trans->Type eq 'CustomField') {
52 return 1 if !defined($field);
53 my $cf = RT::CustomField->new($self->CurrentUser);
55 return 1 if defined($cf->Id) and $trans->Field == $cf->Id;
62 my %args = ( 'QueueObj' => undef, @_ );
63 my $cfs = RT::CustomFields->new($self->CurrentUser);
64 # Allow any ticket custom field to be selected; if it doesn't apply to the
65 # ticket, it will never contain a value and that's fine.
66 $cfs->LimitToLookupType('RT::Queue-RT::Ticket');
67 my @fieldnames = ('', '(any field)');
68 while ( my $cf = $cfs->Next ) {
69 push @fieldnames, $cf->Name, $cf->Name;
74 'label' => 'Custom Field',
76 'options' => \@fieldnames,
79 'name' => 'include_create',
80 'label' => 'Trigger on ticket creation',