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!

  • You can get a relationship name using a global variable $ObjectType directly on the visualforce page: {!$ObjectType.Opportunity.fields.AccountId.RelationshipName} – Sergej Utko Apr 7 '16 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 Apr 7 '16 at 8:30
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

  • 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 Apr 7 '16 at 8:34
  • Ah, ok. Seems this is true for all standard fields – o-lexi Apr 7 '16 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.