+ Start a Discussion

Efficient way to query a custom field from the User table

I'm trying to think of an efficient way to pull the value of a custom field (Cost_Center__c) within the User table. Here's my situation: I'm given a set of Event records and using their OwnerId's, I'm trying to think what'd be an optimal way to pull the user's cost center. My requirement is that I read the currently logged in user's cost center, and given the set of event records, only pull the events with users (the user which the event is assigned to) that have a matching cost center.
I know I could get all the OwnerId's from the Event records and use them to query the user table to find the matching pair, but then I'd be making one API call/comparison, which isn't optimal at all. Also, I could probably add a new field on the Event record that calls an Apex Trigger (after insert) that would check the event's OwnerId, lookup the user table and write the cost center over to this new field.
Is there something else I could do to achieve my goal?
Thanks in advance.

Message Edited by HL-Dev on 09-11-2008 09:21 AM
Best Answer chosen by Admin (Salesforce Developers) 

I decided to go with the Apex class and trigger aproach. Just updating this post to avoid unnecessary replies :-)