You need to sign in to do that
Don't have an account?
Get Required fields from a describeSObjectResult call?
Hello,
Maybe I missed something, but I'm having trouble finding which fields are required based on the results of a describeSObjectResult. I've tried searching through the documentation and other postings, but did not come up with much information.
What I'm trying to do is loop through the list of fields for a particular object (chosen at run-time) and mark each required field. Unfortunately, it doesn't appear that the the Field objects found in the DescribeSObjectResult object have an "isRequired" method to easily tell. I tried to cobble something together, assuming that if isNillable and isDefaultedOnCreate were both false, then it was required, but this doesn't appear to be completely accurate.
I would appreciate any help. Perhaps I'm missing something or there is another approach that I can take. Thanks!
All Answers
I believe you're on the right path. Just one thought, is really a must for the field to be updateble in order to be required?
I think a field is required if and only if:
IS Creatable
IS NOT Nillable
IS NOT Defaulted on Create