You need to sign in to do that
Don't have an account?
reference Opportunity Owner (Lookup(User)) in a custom object formula
Opportunity has two fields I want to reference in another custom object, Owner and CloseDate. For CloseDate I created a formula field returning a date and simply referenced the date field using Opportunity__r.CloseDate. I tried the same method for Owner. I created a formula field returning text and referenced the owner with Opportunity__r.Owner. The former works. The latter gives a syntax error stating Owner is not a field.
When I check the Opportunity object it says the field name is "Owner". What is wrong? A possible clue is that Owner is data type Lookup(User).
try with
It should work for you.
Closer, but not quite there. No syntax error but I get the actual owner ID value instead of their name. Is there a function in which I can use that ID to return the name?
Or perhaps I'm approaching this the wrong way by using a formula? I tried creating a master-detail field but that didn't work either.
If you want to get the name of the Owner then you can do something like this :
"Opportunity__r.Owner.Name"
And if you want to get the Id of the Owner then you can do like this :
"Opportunity__r.OwnerId"
It depends upon your approach, what exactly you are trying to do with these. If you just want to display it as text then
"Opportunity__r.Owner.Name" will work for you, but if you want to put it in another lookup then you need Id for sure and name will be fetched out automatically.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Ankit,
You know that "Owner" is not traversable in formulas, right? As odd as it seems, it just doesn't work. "Owner.Name" seems perfectly reasonable, yet if you try it, you'll see it won't work. This is an obscure limitation that's been around at least as long as I recall formula fields being around.
Trauts,
Regrettably, there is no way to display the owner's name directly in a formula. There is a workaround, though. Create a custom user lookup field on opportunities, and have that populated (via a trigger) with the current owner ID. You can then use: "Opportunity__r.Owner__r.Name".
The trigger would be as follows:
Test method you'd need to install along side the trigger for deployment:
This is the recommendation I've given to several clients that have all had this sort of request (and, oddly, I think it's always a custom object that links to an opportunity!).
Let me know if you have any troubles.