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

Is there an easy way to count the number of custom fields I am using?

Short of going through them one by one on there a counter somewhere, or a report that I can run?
var des = sforce.connection.describeSObject("account");
var fields = des.getArray("fields");
var count = 0;
for (var i=0; i<fields.length; i++) {
  if(fields[i].name.match(/.__c/) != null){

The javascript code above will give you the number of custom fields.
You can easily run this in the debug shell.

Ok, so I don't mean to sound dumb....but maybe I am...  Anyway, do I use that code in a custom field?  I am assuming I would paste it somewhere, but I am afraid I am not quite sure where.  Can you give me a little mor instruction on how to use it?
Thanks so much for your help!!
You have two options:

1. you can create an SControl with the above code and run it.
See Ajax Toolkit docs for details.

2. You can install this AppExchange app.
Then follow these steps to run the above code.

  Select Ajax Tools app, Ajax Tools Tab and click to open link at the top.
  Click the the Shell Icon on the top-right.
  Select the Multi-Line toolbar icon.
  Cut and paste the above code, in the text box.
  Then Ctrl-enter to run this code.


Thanks Cheenath,


It still looks a little over my head, but definitely some stuff to read and learn about.  Thank you so much for your help!