Below is sample code that demonstrates this approach, code that can be adapted for any standard or custom object.
Insights and lessons learned from designing and implementing cloud solutions on the Salesforce1 Platform. Side adventures into Heroku with Ruby on Rails apps also included.
Tuesday, September 3, 2013
Listing Required Fields for an Object in Salesforce Using Apex Code
Sometimes it's desirable or necessary to get a list of all required fields for a particular Salesforce object, especially for subsequent processing in Apex. Instead of hard-coding this list, which is not sustainable or maintainable long-term, a better approach is to use Salesforce field describe results and the isNillable() method.
Labels:
Apex,
describe,
field,
object,
Salesforce