[rt-users] Search old tickets from within scrip

Ruslan Zakirov ruz at bestpractical.com
Tue Aug 7 19:26:21 EDT 2007

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

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 <kae at midnighthax.com> 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: sales at bestpractical.com
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.

More information about the rt-users mailing list