[rt-users] Custom Condition using a CustomField

Andy Harrison ah30 at harrisonfamily.com
Fri Feb 6 15:50:57 EST 2004


Aside from my previous question, I'd also like to detect the value of
a CustomField and add a value to the CCs field based on the
CustomField's value in the newly created ticket.

To experiment with a user defined condition on an existing field, I
successfully used the following:

Description: TestCreate
Condition: User Defined
Custom Condition:
   use RT::CurrentUser;
   my $User = new RT::CurrentUser();
   $User->Load($self->TicketObj->Creator);
   if (($self->TransactionObj->Type eq "Create") and 
      ($self->TicketObj->Subject =~ /testing/i)) {
      return(1);
   } else {
      return(undef);
   }

Action: Notify Requestors, CCs and AdminCCs
prep:
cleanup:
Template: TestOnCreate

This works and happily fires off an e-mail using the TestOnCreate
template that I created just for this one test.


The goal I'm looking for is:

if CustomField-40 = "somevalue" 
push CCs array, "test\@example.com"


I'm currently trying this in the CustomCondition field:

    use RT::CurrentUser;
    use RT::CustomField;
    my $User = new RT::CurrentUser();
    my $CustomFieldObj = RT::CustomField->new($User{'CurrentUser'});

    $User->Load($self->TicketObj->Creator);
    if (($self->TransactionObj->Type eq "Create") and 
       ($self->TicketObj->CustomField-40 =~ /GWI/i)) {
       return(1);
    } else {
       return(undef);
    }

But it yields the following error in the log:

[Fri Feb  6 20:33:02 2004] [error]: Scrip 93 IsApplicable failed:
Global symbol "%User" requires explicit package name at (eval 1983)
line 4.                                                               
                                               
(/usr/local/rt3/lib/RT/Condition/UserDefined.pm:45)



Any help would be appreciated.  Thanx!

-- 
Andy Harrison
(full headers for details)




More information about the rt-users mailing list