apex-enterprise-patterns / fflib-apex-common

Common Apex Library supporting Apex Enterprise Patterns and much more!
BSD 3-Clause "New" or "Revised" License
899 stars 514 forks source link

fflib_SObjectDescribe.cls fails to resolve cross-object field paths for Person Accounts #463

Closed ImJohnMDaniel closed 12 months ago

ImJohnMDaniel commented 12 months ago

Describe the bug The Schema.SObjectField getField(String, Boolean) method in fflib_SObjectDescribe does not resolve cross-object paths when those paths are Person Account specific. In the Person Account scenario, the path would be from a custom field on the Contact object to a field on the Account object. In that case, the relationship path would end with __pr and not the typical __r.

The fflib_SObjectDescribe class needs to be adjusted to handle this scenario correctly.

To Reproduce

  1. Setup a custom field lookup from Contact to Account where Person Account feature is enabled.
  2. Use fflib_SObjectDescribe.getField(String, Boolean) method to resolve the field path

Expected behavior The custom field on the Contact object should be returned

Screenshots and text of error observed The method returns null

Version Latest version as of 8/23/2023