[rt-users] Default value
Mathew Snyder
theillien at yahoo.com
Mon Sep 24 10:04:06 EDT 2007
I have one DV that I set to a default value whenever a ticket is created. I've
tried to port this over to another queue with a different CF/value but it
doesn't seem to work. Here's the code:
my $CFName = 'Environment';
my $DefaultValue = 'default_value';
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 => 7 );
unless( $CFObj->id ) {
$RT::Logger->warning("custom field '$CFName' isn't global or defined for
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;
The only thing I've changed between the two queues is the name of the CF, the
value of the CF and the queue number as it is stored in the DB. Anyone have any
thoughts as to why this isn't working?
--
Keep up with me and what I'm up to: http://theillien.blogspot.com
More information about the rt-users
mailing list