Skip to content

Instantly share code, notes, and snippets.

@Patlatus
Created October 18, 2018 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Patlatus/bb4c964f72ddfb60bbd4710bb34597b9 to your computer and use it in GitHub Desktop.
Save Patlatus/bb4c964f72ddfb60bbd4710bb34597b9 to your computer and use it in GitHub Desktop.
Anon.apex to convert custom object records into custom metadata records
MD.updateAndDeployMetadata(
[ SELECT Field1__c, Field2__c, Field3__c, Field4__c FROM Object__c   ],
CustomMetadata__mdt.sObjectType,
new Map<SObjectField, SObjectField>{
Object__c.Field1__c=> CustomMetadata__mdt.Field1__c,
Object__c.Field2__c=> CustomMetadata__mdt.Field2__c,
Object__c.Field3__c=> CustomMetadata__mdt.Field3__c,
Object__c.Field4__c => CustomMetadata__mdt.Field4__c
},
'X+Field1__c+_+Field2__c',
'Field3__c+ +Field4__c '
);
@Patlatus
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment