[rt-users] [Fwd: Create Ticket but only if Custom Field is...]

Kenneth Crocker KFCrocker at lbl.gov
Mon Nov 5 15:58:44 EST 2007


Matt,


	Make sure the stage is set to "TransactionBatch". Then, if the Custom 
Field is supposed to have already been modified BEFORE the transaction 
to resolve, you might try something like this:

# condition execution on trans new status & ticket Custom Field value

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

return ($trans->Type eq "Status" &&
         $trans->NewValue eq "resolved" &&
         $ticket->FirstCustomFieldValue('Your CF Name') eq "whatever");


	If both are to happen at the same time, then try this:

# condition execution on trans new status & new trans Custom Field value

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 => "Your CF Name");
      return 0 unless $cf->id;
      if  ($trans->Field == $cf->id &&
           $trans->NewValue eq "whatever")
           {
            return 0 unless ($trans->Type eq "Status" &&
                             $trans->NewValue eq "resolved")
           }
     }

return 0;


	Hope this helps.


Kenn
LBNL


On 11/5/2007 12:14 PM, Matt Westfall wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> There are two TransactionObj there.  So would
> 
> unless ( $self->TransactionObj->Type eq "Resolved" &&
> $self->TransactionObj->Field == FIELD_ID )
>        { return 0; }
> 
> return 0 unless $self->TicketObj->FirstCustomFieldValue('Followup') =~
> /Yes/i;
> 
> 1;
> 
> 
> The first check would 1) ensure that the ticket is being resolved &&
> That the CustomField is Set.
> 
> Then if Followup is Yes, it would then return 1?
> 
> What is the purpose of self->transactionobj->Field == ####??
> 
> Should I just be checking for if it's Resolved, and if so, checking value?
> 
> Thanks,
> Matt
> Tim Wilson wrote:
>>>>> On Mon, Nov 5, 2007 at  1:41 PM, in message <472F7200.8080507 at factory7.com>,
>> Matt Westfall <mwestfall at factory7.com> wrote: 
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> I did see that page on the Wiki.  However, I am trying to take an action
>>>  when the ticket is resolved, and if a custom field is something.
>> On this part...
>>
>> unless (
>>  ( $self->TransactionObj->Type eq "CustomField"
>>    &&  $self->TransactionObj->Field == FIELD_ID )
>>  ||  $self->TransactionObj->Type eq "Create"
>>  ) {
>>    return 0;
>> }
>>
>> return 0 unless $self->TicketObj->FirstCustomFieldValue('CUSTOM_FIELD_NAME') =~ /CUSTOM_FIELD_VALUE/i;
>>
>> 1;
>>
>> You could probaby change the TransactionObj type to "Resolved."
>>
>> -Tim
>>
>>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> 
> iD8DBQFHL3mIb/8X6V5MpAURAjxoAKCmS78HjL9FyNLpp7HRn7pHTHpcVQCg2C0J
> maKJYisFKVYAeZk9dIZJXmQ=
> =I1eL
> -----END PGP SIGNATURE-----
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> SAVE THOUSANDS OF DOLLARS ON RT SUPPORT:
> 
> If you sign up for a new RT support contract before December 31, we'll take
> up to 20 percent off the price. This sale won't last long, so get in touch today. 
>     Email us at sales at bestpractical.com or call us at +1 617 812 0745.
> 
> 
> Community help: http://wiki.bestpractical.com
> Commercial support: sales at bestpractical.com
> 
> 
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
> Buy a copy at http://rtbook.bestpractical.com
> 



More information about the rt-users mailing list