[rt-users] Copy value of one custom field to another

Kenneth Crocker KFCrocker at lbl.gov
Tue Jun 24 13:31:31 EDT 2008


Laura,


	I know it is easier to use RT to make a CF mandatory, but in this case, 
since only one Queue needs it to be, try this approach: I think you 
would save yourself a lot of maintenance time by having just one CF, 
make it a "global" application, set the group rights as needed per 
group/queue and write just 1 scrip to make sure the field isn't empty 
when someone in that one queue tries to resolve/open/whatever the 
ticket. You won't have to deal with redundant CF's, you won't have such 
a complicated scrip, the group rights will be easier to maintain and you 
have just one simple piece of code to ensure that the CF isn't empty in 
the one queue. Just a thought.


Kenn
LBNL

On 6/24/2008 9:25 AM, Laura Grella wrote:
> I have one custom field (customer) which is mandatory for a certain queue
> (customer support). I don't want this field mandatory in all queues, but I
> want all queues to be able to search on it. The only way I was able to get
> around this was to create a second custom field and make it a global field,
> and users can see it but can't modify it. I am writing a scrip in the
> customer support queue that will copy the mandatory custom field into the
> global one. It is not working and is always empty. Here is the code. Does
> anyone see anything wrong?
> 
> Condition: On Create
> Action: User Defined
> Template: Blank
> Stage: TransactionCreate
> 
> Custom action preparation code: return 1;
> 
> Custom action cleanup code:
> 
>  #Define the Custom Field Names we are going to take from and write to.
>     my $CFNameFrom = 'Customer;
>     my $CFNameTo = 'GlobalCustomer';
> 
>     #Transaction Association
>     my $txnObj = $self->TransactionObj;
> 
>     my $ticketObj  = $self->TicketObj;
> 
>     my $queueObj   = $self->TicketObj->QueueObj;
> 
>     my $CFObj    = RT::CustomField->new($RT::SystemUser);
>     my $CFNewObj = RT::CustomField->new($RT::SystemUser);
> 
>     #Grab the Custom Field we're using for the switch.
> 
>    $CFObj->LoadByNameAndQueue(Name => $CFNameFrom, Queue => $queueObj->id);
>        
>    #Grab the Custom Field we want to set.
>    $CFNewObj->LoadByNameAndQueue(Name => $CFNameTo, Queue => $queueObj->id);
> 
>    my $cfValue = $ticketObj->FirstCustomFieldValue($CFNameFrom);
>    my ($st, $msg) = $ticketObj->AddCustomFieldValue(
>                                  Field => $CFNewObj->id,
>                                  Value => $cfValue,
>                                  RecordTransaction => 1
>                            );   
> 




More information about the rt-users mailing list