[Rt-devel] TransferCustomFieldValues for custom field working
Juan Ramón Alfageme Mata
JRamon.Alfageme at alhambra-eidos.com
Thu Apr 14 06:02:49 EDT 2005
Finally I get it to work, I tested without problems with CustomFields with single and multiple values, that version works from in RTIR to transfer the values from a Incident Report to an Incident:
Description:
TransferCustomFieldsValue NameOfCustomField
Condition:
On Transaction
Action:
User Defined
Template:
Global template: Blank
Custom condition:
Custom action preparation code:
return 1;
Custom action cleanup code:
my $CFName = 'NameOfCustomField';
my $RecTransaction = 1;
my $Reference = $self->TicketObj->Members->First;
if ($Reference){
my $SourceTicket = $Reference->BaseObj;
my $CFValues = $SourceTicket->CustomFieldValues($CFName);
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 ) ) {
while (my $CurrValue = $CFValues->Next) {
my( $st, $msg ) = $self->TicketObj->AddCustomFieldValue( Field => $CFObj->id, Value => $CurrValue->Content, RecordTransaction => $RecTransaction );
}
}
}
return 1;
Probably it must be modified to transfer from Incidents to Incident Reports, Blocks and Investigations.
More information about the Rt-devel
mailing list