Activity › Forums › Salesforce® Discussions › Can we create custom object through Salesforce apex code?
-
Can we create custom object through Salesforce apex code?
Posted by shariq on July 21, 2017 at 5:59 AMI want to create custom object and fields to it through apex code.
Parul replied 7 years, 9 months ago 3 Members · 2 Replies -
2 Replies
-
Hello shariq,
You can create a custom object using Metadata API
CRUD-Based Metadata Development
Use the CRUD-based metadata calls to create, update, or delete setup and configuration components for your organization or application. These configuration components include custom objects, custom fields, and other configuration metadata. The metadata calls mimic the behavior in the Salesforce user interface for creating, updating, or deleting components. Whatever rules apply there also apply to these calls.Metadata calls are different from the core, synchronous API calls in the following ways:Metadata API calls are available in a separate WSDL. To download the WSDL, log into Salesforce, from Setup, enter APIin the Quick Find box, then select API and click the Download Metadata WSDL link.
After logging in, you must send Metadata API calls to the Metadata API endpoint, which has a different URL than the SOAP API. Retrieve the metadataServerUrl from the LoginResult returned by your SOAP API login() call. For more information about the SOAP API, see the SOAP API Developer’s Guide.
Metadata calls are either synchronous or asynchronous. CRUD calls are synchronous in API version 30.0 and later, and similar to the API core calls the results are returned in a single call. In earlier API versions, create, update, and delete are only asynchronous, which means that the results are not immediately returned in one call.
There are synchronous metadata calls that map to the corresponding core SOAP API synchronous calls.createMetadata() maps to the create() SOAP API call.
updateMetadata() maps to the update() SOAP API call.
deleteMetadata() maps to the delete() SOAP API call. - [adinserter block='9']
-
You can create a custom object using Metadata API
THanks
Log In to reply.