tags:

views:

64

answers:

2

I've got an application that reads Lead records from Salesforce via the API and I want to link the Lead Owner field to an attribute in the application. The Lead Owner field doesn't up in the list of available fields but all the custom fields do.

So, my first attempt at a solution was to create a custom field that displayed the Lead Owner name. In the SF formula editor, as far as I can tell, it doesn't display the actual data field but instead displays the ID string. Which is pretty meaningless in the context that I need it for.

alt text

Is there a way that we can get at the data in the object that the ID string references?

alt text

I have the RED BOX but need the GREEN BOX.

+2  A: 

Salesforce allows access to related data through what they call relationship queries. Instead of joining, you specify the query like this:

System.debug([SELECT Owner.Name FROM Lead WHERE Id = '00QS00000037lvv'].Owner.Name);

Try running that in the system log, just replace the lead ID with one that you're looking at.

When accessing the data through the API, the principle is the same, your proxy objects should allow you to access Lead.Owner.Name.

Adam
A: 

VLOOKUP function would be a good try, but

  • it's available only in validation rules, not in field definitions
  • it can be used only on custom objects and you need data from User

I'd say you need to query from your application for

SELECT Owner.FirstName, Owner.LastName FROM Lead

Other than that... some "after insert, after update" trigger that would populate your custom field when owner changes?

eyescream

related questions