On Fri, Mar 23, 2012 at 01:27:48AM +0100, Maciej Dobrzanski wrote: > I created two custom fields called "Customer ID" - one is for Ticket object, > while the other is for User. The name is not unique, but these are two > different CFs with different identifiers. In a callback I need to figure out > the appropriate field id depending on the context - whether a ticket or a > user details are being displayed. However the normal interface does not > really seem to allow that. In RT::CustomField, LoadByName() only takes field > name and optionally also queue name/id(?). The effect is that > LoadByName(Name => 'Customer ID') always loads the "first" CF it finds by > the name 'Customer ID', which does not necessarily mean the right one. Is > there any other way around it or do I really need to loop through all the > CFs as RT::CustomFields comes with LimitToLookupType(), which might allow > looping through RT::Queue-RT::Ticket or RT::User fields as needed.
There are a number of ways to do it. Make a custom fields collection, LimitToLookupType and also use Limit to limit on the Name. Call CustomFields on a Ticket or User object and then Limit that collection to a particular name. You can string multiple Limit calls together to build more complex queries. You can read more about the syntax in DBIx::SearchBuilder. -kevin
pgpJv59Tenkj1.pgp
Description: PGP signature
