2

Can we say that all standard lookups/master-details/polymorphic fields follow a consistent naming convention across all standard objects? I'm talking about this pattern:

  • field name = field relationship name + "Id"

Examples:

  • field name = OwnerId/WhatId/ParentId/AccountId
  • field relationship name = Owner/What/Parent/Account

So far I haven't come across a negative case but I'm not confident about it either. Basically I want to see if I can get the field name directly from the relationship name, with as little effort as possible. That means doing a describe call is something I'm obviously trying to avoid here.

Please note that this question is not seeking design advice. Thanks!

2
  • You can get a relationship name using a global variable $ObjectType directly on the visualforce page: {!$ObjectType.Opportunity.fields.AccountId.RelationshipName} Commented Apr 7, 2016 at 8:22
  • Appreciate the reply but that's not really the question. The question is about whether all standard foreign keys in Salesforce follow the same field name/relationship convention. I'm not using Visualforce for this. I just need to know if my hypothesis is correct.
    – Mossi
    Commented Apr 7, 2016 at 8:30

1 Answer 1

0

<apex:outputField value="{!Opportunity.Account}"/> would be rendered the same as a lookup field on page layout - Account name with a hyperlink to itself

2
  • Thanks, but I'm not using Visualforce and I'm not looking to get a lookup field rendered on a page. The question is simple: I want to know if my hypothesis about foreign keys in Salesforce is correct.
    – Mossi
    Commented Apr 7, 2016 at 8:34
  • Ah, ok. Seems this is true for all standard fields
    – o-lexi
    Commented Apr 7, 2016 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .