You need to sign in to do that
Don't have an account?

Update an existing custom metadata in apex class.
Can I do a soql on existing custom metadata and update the record in apex class? When I try that it says list cannot be updated.
You need to sign in to do that
Don't have an account?
public void handleResult(Metadata.DeployResult result, Metadata.DeployCallbackContext context) {
if (result.status == Metadata.DeployStatus.Succeeded) {
System.debug(' success : '+ result);
} else {
System.debug(' fail : '+ result);
}
}
public static void createUpdateMetadata(String fullName, String label, Map<String, Object> fieldWithValuesMap){
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
customMetadata.fullName = fullName;
customMetadata.label = label;
for(String key : fieldWithValuesMap.keySet()){
Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
customField.field = key;
customField.value = fieldWithValuesMap.get(key);
customMetadata.values.add(customField);
}
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
mdContainer.addMetadata(customMetadata);
CreateUpdateMetadataUtils callback = new CreateUpdateMetadataUtils();
Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, callback);
}
}
I was looking for updating the existing metadata record. The code above is for creating a new record and updating its fields.
Thanks,
Priya