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
                           );   

-- 
View this message in context: 
http://www.nabble.com/Copy-value-of-one-custom-field-to-another-tp18094637p18094637.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.

_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com

Reply via email to