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
Vishal RanjanVishal Ranjan 

Creating Multiple object Using Metadata Api in single web service call.

I have to create Multiple objects in single web service call. I am using Metadata Api to create objects in salesforce.
Is it possible to create multiple object in single web service call ? If it is possible then please guide me, How I can create it.
Hi Vishal,

You can refer below mentioned URL for achieving this functionality:
Vishal RanjanVishal Ranjan
Hi Pankaj.
Firstly thank you for your response!
I saw that post shared by you and the code shared by @Mr. Andy Fawcett is below. you can see when he is calling web service he is passing data for only one object.
and I somewhere read, in apex we can call webservice 10 times only in one execution, means we can create maximum 10 objects using this code. I have to create more than 10 in one execution then what will be the solution ?
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'Test__c';
customObject.label = 'Test';
customObject.pluralLabel = 'Tests';
customObject.nameField = new MetadataService.CustomField();
customObject.nameField.type_x = 'Text';
customObject.nameField.label = 'Test Record';
customObject.deploymentStatus = 'Deployed';
customObject.sharingModel = 'ReadWrite';
MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { customObject });

Hi Vishal,

If you have to create more than 10 objects, then you will have to make the transaction asynchronous by utilising the concept of future methods or batch process. Use @future(callout=true) annotation for future method. You can refer below mentioned post for implemeting the future method: