[Rt-devel] RE: TransferCustomFieldValues for custom field working

Juan Ramón Alfageme Mata JRamon.Alfageme at alhambra-eidos.com
Thu Apr 14 06:41:34 EDT 2005


There are only two changes to transfer values from Incidents to Reports, Investigations or Block:

	"Members->First" changes to "MemberOf->First"
	"$Reference->BaseObj " changes to "$Reference->TargetObj"

 	
Juan Ramón Alfageme Mata
+34 91 787 23 00 alhambra-eidos.com
 	
 
 
 
 
 

-----Mensaje original-----
De: Juan Ramón Alfageme Mata 
Enviado el: jueves, 14 de abril de 2005 12:03
Para: 'rt-devel at lists.bestpractical.com'
Asunto: TransferCustomFieldValues for custom field working


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