3

I want to make a tool which will create custom objects & fields by uploading data through a CSV file. I have created the same using MetaDataService API. I'm able to create object, but can create only 5 fields at a time. If i try to upload more than 5 fields, then i'm getting the following error:- Too many callouts:11 Any suggestions?

1
  • I'd personally write this tool as a desktop/external application, not on platform, just so you don't have to jump through so many hoops. Commented Nov 2, 2013 at 9:15

3 Answers 3

1

You'll have to make a "batch apex" function if you want to call out many times. You can use Database.Stateful to store the results of the transaction, which you can stream back to the client after completion.

1

If you use the Apex Metadata API, you can leverage the BatchCreate class to create metadata items (including dependencies). Here is an example...

  // Pass the Metadata items to the job for processing, indicating any dependencies
    MetadataCreateJob.run(
        new List<MetadataCreateJob.Item> { 
                new MetadataCreateJob.Item(customObject),                   
                new MetadataCreateJob.Item(customField1, null, true), // Set wait to true, to process after object creation
                new MetadataCreateJob.Item(customField2),  
                new MetadataCreateJob.Item(apexPage, null, true) // Set wait to true, to process after field creation
            },
        new MetadataCreateJob.EmailNotificationMetadataAsyncCallback());     
-1

Try to change the api version of your class/page to 28.0. I think salesforce had improved the governor limit recently in their latest versions.

1
  • Governor limits haven't really changed (and the new limits aren't going to help, either). Commented Sep 3, 2013 at 3:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.