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

Unable to complete Trailhead Challenge
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
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
Please note that Questions about how to pass Trailhead challenges are not on topic, because these challenges are intended to be independent demonstrations of your abilities.Trailhead Help (https://trailhead.salesforce.com/en/help?support=home)can provide assistance for situations where Trailhead does not appear to be functioning correctly. You can reach out to them if this is the case.
Thanks!
May be I worded it incorrect.. I am not looking for a solution. If you look at the problem - the error message is very obvious.
I am trying to figure out if it could be a Trailhead issue and if others have faced the issue.
Please share your error Here.
maybe it should not be String and here you use this as a String Value :
customField.field = 'customField__c ';
make sure the value dataType and put that type value only.
if you have any query please comment.
---------------
If you find your Solution then mark this as the best answer to close this question.
Thank you!
Regards,
Suraj Tripathi