[rt-devel] Custom Condition using a CustomField

Andy Harrison ah30 at harrisonfamily.com
Mon Feb 9 11:56:39 EST 2004


I'd 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 when I use a subject with the word "testing" in it.


The goal I'm looking for is:

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


One of the snippets I've tried is this code 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-devel mailing list