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
Ravi NarayananRavi Narayanan 

Tooling API - Creating Custom Fields Programatically

Hi Guys,

I have a requirement where i have to create almost 50 fields. I came to know that it is possible using MetaData API and tried to create and it is working fine. But the code i got from gitHub is very big and its almost impossible to edit it as the browser hangs whenver i open the class.

Recently i came to know that it is Possible to create fields using TOOLING APII read the documentation given by Salesforce.com.when i try to create a instance of Apexclass , it is working fine (Apexclass a=new ApexClass();).

But the same logic is not working for customFields. Is there any other way that we should follow for creation of CustomFields?

CustomField c=new CustomField(); --- THIS DOES NOT WORK ! ! Seems there is no such table named CustomField.

Please help

ShashankShashank (Salesforce Developers) 
Did you check the API version? CustomField is available only from version 28.0 and above.