[Rt-devel] Problem with DefaultCustomFieldValue

Juan Ramón Alfageme Mata JRamon.Alfageme at alhambra-eidos.com
Fri Feb 18 05:30:27 EST 2005


I tried to create this global and queue specific script without success, I have a Global Ticket Custom Field "Provider" It's a select one value field the default value I want to use is "BT" instead of "(no value)"

Condition: On Transaction
Custom Condition:
Action: User defined
Custom action preparation code: return 1;
Custom action cleanup code:
  my $CFName = 'Tipo';
  my $DefaultValue = 'Generica';
  my $RecTransaction = 1;

  my $QueueObj = $self->TicketObj->QueueObj;
  my $CFObj = RT::CustomField->new( $QueueObj->CurrentUser );
  $CFObj->LoadByNameAndQueue( Name => $CFName, Queue => $QueueObj->id );
  unless( $CFObj->id ) {
    $CFObj->LoadByNameAndQueue( 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->AddCustomFieldValue(
                                          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


Any suggestions? 


Thanks.

RT 3.4.1
RTIR 1.1.5



More information about the Rt-devel mailing list