A data architect on my team recently asked me if I could get him a list of universally required fields from the Account object. The easiest way was to click into each field, check if it’s required and accordingly add it to the list. What’s the fun in doing that, right? So I scourged the Salesforce stackexchange and Developer forums trying to find code which would utilize the DescribeSObjectResult class for querying the needed metadata. I found enough to come up with a code snippet that can be executed as Anonymous Apex and the resulting system debug would provide us with the list of required fields.
You need to plug in the appropriate object name in the first line of the Apex code, execute the code and then see the debug to log to get the desired list. Convenient but I thought we could do better and that’s when I approached a dear friend Deepak Anand. We discussed it and contemplated a way to provide a better user experience. We decided to spin up a user interface to give the user the ability to choose multiple objects and then click on a button to see the universally required fields along with other miscellaneous information for the selected object. Now there might be multiple apps out there which let you do this and much more but the idea was to learn, test it for ourselves and see how it pans out. And we had a tad bit of time to kill anyway. So this is what our time killing produced:
Like it? Then go install it!
Production or Dev Org: