[Rt-devel] Problem with DefaultCustomFieldValue
Andy Harrison
aharrison at gmail.com
Fri Feb 25 09:19:11 EST 2005
On Wed, 23 Feb 2005 13:04:05 +0100, Juan Ramón Alfageme Mata
<JRamon.Alfageme at alhambra-eidos.com> wrote:
> Now I have the following global and queue specific scripts, but still nothing happens.
>
> Condition: On Transaction
> Custom Condition:
> Action: User defined
> Custom action preparation code: return 1;
> Custom action cleanup code:
> my $CFName = 'Provider';
> my $DefaultValue = 'BT';
> my $RecTransaction = 1;
>
> my $QueueObj = $self->TicketObj->QueueObj;
> my $CFObj = RT::CustomField->new( $QueueObj->CurrentUser );
> $CFObj->LoadByName( Name => $CFName, Queue => $QueueObj->id );
> unless( $CFObj->id ) {
> $CFObj->LoadByName( Name => $CFName, Queue => 0 );
> unless( $CFObj->id ) {
> $RT::Logger->warning( "$CFName doesn't exist, Queue -". $QueueObj->Name ."-" );
> return undef;
> }
> }
>
> unless( $self->TicketObj->FirstCustomFieldValue( $CFObj->id ) ) {
> my( $st, $msg ) = $self->TicketObj->SetContent(
> Field => $CFObj->id,
> Value => $DefaultValue,
> RecordTransaction => $RecTransaction );
> unless( $st ) {
> $RT::Logger->warning( "Couldn't set $DefaultValue as value for CF $CFName:". $msg );
> return undef;
> }
> }
> return 1;
> Template: Global template: Blank
>
>
I think you have your prep and cleanup blocks backwards. Try
switching that. You should probably wipe out either the global or
queue specific scrip while you're testing. Unless that's a global
custom field, you should probably wipe out the global scrip.
--
Andy Harrison
More information about the Rt-devel
mailing list