[rt-users] How set a default value on Custom Field when Change Owner

Thomas Sibley trs at bestpractical.com
Tue Mar 1 10:02:14 EST 2011


On 01 Mar 2011 08:04, mauricio.leite at planalto.gov.br wrote:
> I made  a scrip to set a value on CF when changing owner, but is not
> working.
> Does somebody can help me.
> My code bellow:
> 
> use RT::Ticket;
> use RT::CustomField;
> my $Ticket = $self->TicketObj;
> my $CFName = 'Tipo de Defacement';
> my $QueueObj = $Ticket->QueueObj;
> my $CFObj = RT::CustomField->new( $QueueObj->$self->CurrentUser );

Have you looked in your error logs?  That should always be the first step.

The line "$QueueObj->$self->CurrentUser" above, while valid Perl, is
really not at all what you want there (it's using the value of $self as
a method name).

Either $QueueObj->CurrentUser or $self->CurrentUser is probably sufficient.

Thomas

> $CFObj->LoadByNameAndQueue( Name => $CFName, Queue => $QueueObj->id );
> $Ticket->AddCustomFieldValue(   Field => $CFObj->id,
>                                          Value => "Desfiguracao de Sitio",
>                                          RecordTransaction => 1);
> Thanks.
> 




More information about the rt-users mailing list