<<< my $tickets = RT::Tickets->new( $RT::SystemUser ); $tickets->FromSQL("Requestor.EmailAddress = '$address' AND 'CustomField.{Customer}' IS NOT NULL"); # fetch from DB only first one ticket $tickets->RowsPerPage(1);
my $ticket = $tickets->First; return undef unless $ticket; return $ticket->FirstCustomFieldValue('Customer'); >>> * code not tested * I'm not sure if 3.6.1 supports 'IS NOT NULL' for CFs, but 3.6.latest should I can suggest you another way with two scrips: 1) Update Company field of requestors when an user update customer custom field 2) On ticket create check if a requestor has defined Company property and update the field On 8/8/07, Keith Edmunds <[EMAIL PROTECTED]> wrote: > RT 3.6.1 > > We have one custom field per ticket, "Customer", of type 'select one > value'. So far, we've set that value manually on each new ticket, but I'd > like to automate it. > > What I'd like to do, within a script, is search for the last ticket from > this requestor and set the customer custom field to the same value. In > pseudo SQL terms: "select customer from custom_fields where > requestor_address = '$requestor' and customer != null order id desc limit > 1". How can I do that kind of search from a script? I'm not looking for > in-depth instructions, just a pointer as to the best way of doing this. > > Thanks, > Keith > _______________________________________________ > 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 > -- Best regards, Ruslan. _______________________________________________ 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