I am writing some business rules which expect data to be captured properly in many fields while record creation. Most of the fields for most of the records are blank and not captured by user. We need to put some validation logic like make important fields required etc. We need a way to find fields on objects which are null for most of the records. How can we do a SQL COUNT(*) kind of thing to find null count for columns across sObjects.
1 Answer
How can we do a SQL COUNT(*) kind of thing to find null count for columns across sObjects.
You could probably use the SOQL Aggregate Functions. In particular COUNT() in combination with GROUP BY.
E.g.
SELECT Count(Id)
FROM Account
WHERE FieldThatMightBeNull__c == null