0

Someone added a field called OwnerId to the Opportunity. It seems to be a text field with no lookup to the User object, even though it is holding a User id.

I tried to build a new formula field on Opportunity, a WorkersId field that would pull the EmployeeId from the User object. But I couldn't do this as a formula because the OwnerId field wasn't a real relationship field.

I'm curious if I have to write some Apex code to copy the EmployeeId from the User to the Opportunity or is there a formula that can still do this?

8
  • May I know, Why you can't get EmployeeId from User object directly by creating the formula field's using the formula as Owner.employeeId__c in Opportunity object(Field EmployeeId's API name can be varied in your situation)?
    – Raj
    Commented Mar 30, 2023 at 13:38
  • I don't know know why, that's what I'm confused about. At least in the "formula builder" there is no "Owner" there is only an "OwnerId" and it does not allow me to look up anything on the User. Commented Mar 30, 2023 at 13:43
  • "CreatedBy" and "LastModifiedBy" both work the way I expect, they link to a User so I can pull in details from those User objects. But OwnerId does not work that way. Commented Mar 30, 2023 at 13:44
  • 2
    A formula field can never result in a Lookup, but can store the text for an ID from a lookup/master detail/Id field (this is probably why you see it this way). The only way to then use this to be a lookup-like, clickable value is to create a component (e.g. LWC) that presents it that way. There's nothing out-of-the-box in Salesforce that will let you treat that text as a clickable link to a record. (Other than some URL-based button that builds the URL using this field's value.)
    – Phil W
    Commented Mar 30, 2023 at 14:10
  • 1
    A formula field can render a URL that is clickable based on ID.
    – identigral
    Commented Mar 30, 2023 at 15:14

0

You must log in to answer this question.

Browse other questions tagged .