summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Condition/CustomFieldChange.pm
diff options
context:
space:
mode:
authormark <mark>2010-11-17 20:44:11 +0000
committermark <mark>2010-11-17 20:44:11 +0000
commit5ef064aeca4a22dbe38b538e65d512d5d398fe2f (patch)
tree81959e7fd86bc537b61cf530983df26b01ca4fba /rt/lib/RT/Condition/CustomFieldChange.pm
parent2a874cdff2e2bc0d5d6920aae306d5b7c3d4aa97 (diff)
create ticket on custom field change, RT#10139
Diffstat (limited to 'rt/lib/RT/Condition/CustomFieldChange.pm')
-rw-r--r--rt/lib/RT/Condition/CustomFieldChange.pm56
1 files changed, 56 insertions, 0 deletions
diff --git a/rt/lib/RT/Condition/CustomFieldChange.pm b/rt/lib/RT/Condition/CustomFieldChange.pm
new file mode 100644
index 0000000..b9228a5
--- /dev/null
+++ b/rt/lib/RT/Condition/CustomFieldChange.pm
@@ -0,0 +1,56 @@
+package RT::Condition::CustomFieldChange;
+use base 'RT::Condition';
+use strict;
+
+=head2 IsApplicable
+
+If a custom field has a particular value.
+
+=cut
+
+# Based on Chuck Boeheim's code posted on the RT Wiki 3/13/06
+
+sub IsApplicable {
+ my $self = shift;
+ my $trans = $self->TransactionObj;
+ my $scrip = $self->ScripObj;
+ my %Rules = $self->Rules;
+ my ($field, $value) = @Rules{'field', 'value'};
+ return if !defined($field) or !defined($value);
+
+ if ($trans->Type eq 'Create') {
+ return 1 if $trans->TicketObj->FirstCustomFieldValue($field) eq $value;
+ }
+ if ($trans->Type eq 'CustomField') {
+ my $cf = RT::CustomField->new($self->CurrentUser);
+ $cf->Load($field);
+ return 1 if $trans->Field == $cf->Id and $trans->NewValue eq $value;
+ }
+ return undef;
+}
+
+sub Options {
+ my $self = shift;
+ my %args = ( 'QueueObj' => undef, @_ );
+ my $QueueObj = $args{'QueueObj'};
+ my $cfs = $QueueObj->TicketCustomFields();
+ my @fieldnames;
+ while ( my $cf = $cfs->Next ) {
+ push @fieldnames, $cf->Name, $cf->Name;
+ }
+ return (
+ {
+ 'name' => 'field',
+ 'label' => 'Custom Field',
+ 'type' => 'select',
+ 'options' => \@fieldnames,
+ },
+ {
+ 'name' => 'value',
+ 'label' => 'Value',
+ 'type' => 'text',
+ },
+ );
+}
+1;
+