I want to update custom Metadata Relationship Field using Metadata API. I am using MetadataService.CustomMetadataValue
to add the field and value parameters, but not successful in updating the Relationship field. Although I am able to update other custom Metadata Type field
Below is the code I am using
MetadataService.CustomMetadataValue cmTest = new MetadataService.CustomMetadataValue(); <br/>
cmTest.field='RelationshipField__c'; <br/>
cmTest.value= 'Id of the Parent Record';
Any help on this.
Best Answer
Are you updating an existing field? Or creating a new one and adding a value?
The CustomMetadata and the CustomObject are two different Metadata types, but under CustomMetadata you will find the "values of the fields created in the CustomMetadata" and under CustomObject you will find the CustomMetadata object itself.
For instance, a CustomMetadata named "Off Limit Settings" with a number field named "AccountOffLimitMonths" will be shown as a CustomObject like (file: objects/Off_Limit_Settings__mdt.object):
And the field will be shown under CustomMetadata as (file: customMetadata/Off_Limit_Settings.Off_Limit.md):
If you want to add a new field, modify the first file and deploy it in a package. If you want to modify a field, use the second file.