File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
force-app/main/custom-metadata-saver/classes Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -66,9 +66,19 @@ public inherited sharing class CustomMetadataSaver {
6666 continue ;
6767 }
6868
69+ Schema .SObjectField field = customMetadataRecord .getSObjectType ().getDescribe ().fields .getMap ().get (fieldName );
70+
71+ Object value ;
72+ // Picklist values have to be cast to strings (even though they already look like strings)
73+ if (field .getDescribe ().getType () == Schema .DisplayType .PICKLIST ) {
74+ value = String .valueOf (customMetadataRecord .get (field ));
75+ } else {
76+ value = customMetadataRecord .get (fieldName );
77+ }
78+
6979 Metadata .CustomMetadataValue customField = new Metadata .CustomMetadataValue ();
7080 customField .field = fieldName ;
71- customField .value = customMetadataRecord . getPopulatedFieldsAsMap (). get ( fieldName ) ;
81+ customField .value = value ;
7282 System .debug (LoggingLevel .INFO , ' customField==' + customField );
7383
7484 customMetadata .values .add (customField );
You can’t perform that action at this time.
0 commit comments