0

I have Custom Metadata Type with Metadata Relationship field. I'm trying to insert a new record in it, it runs successfully with no errors, but doesn't insert the row!

Here is my code:

Metadata.CustomMetadata customMetadata =  new Metadata.CustomMetadata();
   customMetadata.fullName = 'Voicesense_score__mdt.1';//+scoreId; 
   customMetadata.label = 'XX1';//+scoreId;

    Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();  
    customField.field = 'scoreId__c' ;
    customField.value = 1;
    customMetadata.values.add(customField);

    customField = new Metadata.CustomMetadataValue();  
    customField.field = 'Status__c' ;
    customField.value = 1;
    customMetadata.values.add(customField);

    customField = new Metadata.CustomMetadataValue();  
    customField.field = 'Voicesense_score_name_Id__c' ;
//    string soqlQuery = 'SELECT QualifiedApiName FROM Voicesense_score_name__mdt WHERE ID__c='+vsScoreNameId;
    customField.value ='X1';
    customMetadata.values.add(customField);

'X1' is the QualifiedApiName of an existing parent field.

Thank you!

  • 1
    Is this all of your code? You don't enqueue a Metadata API deployment here. – David Reed Jun 22 at 23:27
  • No, it's not. but this is the problematic code, because the other code works for different Custom Metadata Types. – user1478469 Jun 23 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.