function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nextdoornextdoor 

count empty fields

Hi,

I want to count how many empty fields are in an object. 

Is there a fast and easy way to do it in VF ?
First I was thinking about something like this :

 

<script type="text/javascript">
var i=0;
if ('{!Object__c.field1}'!=null){
i=i++; 
}
if ('{!Object__c.field2}'!=null){
i=i++; 
}
 ...

 

 But this is too long... 

aballardaballard

Sounds like something you should be doing in your controller/extension via apex.  You can use the describe classes to iterate over all the fields....

nextdoornextdoor

Well I guess I should try the describe class.

Thanks