• ash rod
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi all, 
I am trying to complete below challenge and getting an error. I have copied all details(Challange Link, Code and Error).  

Appreciate your help!


CHALLENGE NAME

https://trailhead.salesforce.com/content/learn/modules/apex_metadata_api/apex_metadata_api_tools?trailmix_creator_id=strailhead&trailmix_slug=prepare-for-your-salesforce-platform-developer-ii-credential

CODE
public class MetadataExample {
    
    public  Metadata.CustomMetadata customMetadata{get;set;}
    public void updateMetadata(){
        
        customMetadata  = new Metadata.CustomMetadata();
        customMetadata.fullName  = 
            'MyNamespace__MyMetadataTypeName.MyMetadataRecordName';
        
        Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
        customField.field = 'customField__c ';
        customField.value = 'New Value';
        
        customMetaData.values.add(customField);
        
        Metadata.DeployContainer deployContainer = new Metadata.DeployContainer();
        deployContainer.addMetadata(customMetaData);
        Id asyncResultId  = Metadata.Operations.enqueueDeployment(deployContainer, null);
    }
}

ERROR