Search code examples
salesforce

How to create a custom field for a standard object in salesforce through API


I would like to know how to create a custom field for a standard object on salesforce using the API. The object I want to create a custom field is the "Contact" object.


Solution

  • Have you heard about "metadata api"? You'd deploy an XML file with your field definition. https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/customfield.htm.Alternatively Tooling API (REST, bit newer than old SOAP one) says it offers POST (create new) and PATCH (update field definition) but I never tried it that way: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_customfield.htm

    You can experiment in Workbench if you don't have any tools. SOAP deployment is in Migration -> Deploy, Tooling can be executed from Utilities -> REST Explorer.