I have a function argument, dfr, that is of type Schema.DescribeFieldResult. Based off this variable, I need to find it's parent SObject and get the Describe Result for it (Schema.DescribeSObjectResult).

From the documentation, I see that I can get an SObjectField either via getController() or getSObjectField(), but SObjectField seems to be a mostly useless class as it's only documented function is getDescribe() which just takes me back to the DescribeFieldResult. (I know that it can also be compared to other SObjectField instances, but this isn't helpful since I don't want to compare it against every field in the org).

Is there some utility function or something I haven't found yet that can at least get the SObject name, or, preferably, the DescribeSObjectResult, for a given DescribeFieldResult?

  • If you mean you want to find the SObjectType that an SObjectField is part of, that mechanism is missing from the API. See e.g. salesforce.stackexchange.com/questions/29911/…. So in any code where you are working with these, you need to pass both values around. – Keith C Feb 27 '18 at 16:14
  • Thanks... that answers in my question. Very disappointing, but should have expected it. – JDB still remembers Monica Feb 27 '18 at 16:16

Browse other questions tagged or ask your own question.