[Rt-devel] Re: Transfer custom field value in ticket creation

Lucas F. Rosada lucas at dextra.com.br
Thu Mar 10 13:02:19 EST 2005


> Someone have any idea abaout how to transfer a custom field value?, when you create a new ticket from another, as for example create a 
> Incident from Incident Report, but instead of selecting it again values for custom field in the Incident use the Report ones.


You can do it by developing an scrip, but we need to have some reference to the "source ticket" (the ticket which have the custom fields we want). Supose the situation:

- We want to copy custom field values of CF1;

- Ticket A (Incident Report) - Have the custom field values we want to copy;
- Ticket B  (Incident) - The just created ticket;

The queues must have the same custom fields (or just with equal names)

- Ticket B REFERS TO Ticket A;

Scrip:
Queue: Incident
Stage: TransactionCreate
Condition: OnCreate
Action: User Defined:
Custom Prepare Code:
	return 1;

Custom Commit code:

# Reaching the referred ticket by the links
my $Reference = $self->TicketObj->RefersTo->Next;
my $SourceTicket = $Reference->TargetObj if ($Reference);

# we get the custom fields
my $CF1Values = $SourceTicket->CustomFieldValues ('CF1');

while (my $CurrValue = $CF1Values->Next) {
	$self->TicketObj->AddCustomFieldValue (Field => 'CF1', Value => $CurrValue->Content);
}

return 1;

I think that's all!

Regards,

-- 
Lucas F. Rosada
lucas at dextra.com.br

Dextra Sistemas
+55 (19) 3256 6722
http://www.dextra.com.br



More information about the Rt-devel mailing list