I have a controller that updates/creates metadata type records. It works fine for the creation of new records, but when I try to update existing records, I get this error
duplicate value found: ObjectAPIName__c duplicates value on TestDeploy2
and when I remove this field from my code, I get this error
'Required fields are missing: [ObjectAPIName__c]'
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
customMetadata.fullName = 'ForgotCustomerStrategySettings.' + fullName;
customMetadata.label = fullName;
Metadata.CustomMetadataValue customField2 = new Metadata.CustomMetadataValue();
customField2.field = 'ObjectAPIName__c';
customField2.value = ObjectAPIName;
customMetadata.values.add(customField2);
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
mdContainer.addMetadata(customMetadata);
PostInstallCallback callback = new PostInstallCallback();
Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, callback);