https://cloras.com/blog/creating-custom-object-and-custom-fields/ code example

Example: https://cloras.com/blog/creating-custom-object-and-custom-fields/

MetadataService.MetadataPort metadataservice = new MetadataService.MetadataPort();
	metadataservice .SessionHeader = new MetadataService.SessionHeader_element();
	metadataservice .SessionHeader.sessionId = UserInfo.getSessionId();
	List  fields = new List ();
	MetadataService.CustomObject customobject = new MetadataService.CustomObject();
	customobject.fullName = 'custom_create__c';
	customobject.label = 'custom created object';
	customobject.pluralLabel = 'custom created objects';
	customObject.nameField = new MetadataService.CustomField();
	customobject.nameField.type_x = 'Text';
	customobject.nameField.label = 'status';
	customobject.deploymentStatus = 'Deployed';
	customObject.sharingModel = 'ReadWrite';
	fields.add(customobject);
	metadataservice.createMetadata(fields);

Tags:

Html Example