[rt-devel] Custom Condition using a CustomField
Ruslan U. Zakirov
cubic at acronis.ru
Mon Feb 9 12:17:46 EST 2004
Andy Harrison wrote:
> 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;
throw it to the bin, you don't need any f* with current user as I think.
RT has $RT::SystemUser which is SU and offer full control over thing, I
don't think you want check permissions.
> 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);
> }
return undef unless ($self->TransactionObj->Type eq "Create");
return undef unless ($self->TicketObj->FirstCustomFieldValue('mycf') =~
/GWI/i);
return 1;
>
> 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.
Error means:
You don't have defined hash with name User, it's true because you have
$User - blessed scalar referense to RT::User instance.
perldoc perltoot
>
> (/usr/local/rt3/lib/RT/Condition/UserDefined.pm:45)
>
>
>
> Any help would be appreciated. Thanx!
>
More information about the Rt-devel
mailing list