function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marc D BehrMarc D Behr 

Converting Custom Metadata field types

I am trying to convert a CMD field from Text to LongTextArea and it appears that you can't convert CMD fields once they are defined. Is this true and if so, why?
 
If I have a text field on an object, I can convert it to LongTextArea, but the same conversion on a CMD object does not appear to be possible. I am not finding any documentation that says I can't do this, but apparently I can't. Has anybody seen where it is documented that this is *not* possible? Without being able to convert the field (since the CMD being used in a SFDX package), it looks like it will take creating a new field, updating all of the code the references the old field, and then deleting the original field unless somebody else has another idea?
Best Answer chosen by Marc D Behr
Alain CabonAlain Cabon
Hi,

IMPORTANT
  • Custom Metadata Types do not support Shield Platform Encryption for fields.
  • Once defined, Custom Metadata Type custom field types cannot be updated. For example, once you define a custom field as Text, you can’t change it to Text Area.

https://help.salesforce.com/articleView?id=custommetadatatypes_fields.htm&type=5&lang=en

Change Field Types for Custom Metadata:
​​​​​​​

If I have a Custom Metadata field of type Number and I want to change it to type Text, the only way is to create a new field, update all my code references to the new field, delete the old field, recreate the old field as a Text field, and then re-update my code references to the new field

https://success.salesforce.com/ideaView?id=0873A000000E6KHQA0
 

All Answers

Alain CabonAlain Cabon
Hi,

IMPORTANT
  • Custom Metadata Types do not support Shield Platform Encryption for fields.
  • Once defined, Custom Metadata Type custom field types cannot be updated. For example, once you define a custom field as Text, you can’t change it to Text Area.

https://help.salesforce.com/articleView?id=custommetadatatypes_fields.htm&type=5&lang=en

Change Field Types for Custom Metadata:
​​​​​​​

If I have a Custom Metadata field of type Number and I want to change it to type Text, the only way is to create a new field, update all my code references to the new field, delete the old field, recreate the old field as a Text field, and then re-update my code references to the new field

https://success.salesforce.com/ideaView?id=0873A000000E6KHQA0
 
This was selected as the best answer
Marc D BehrMarc D Behr
Hi Alain,

Thanks. Not sure whay I was not able to find this, but glad to know that it is documented. Makes working with SFDX a bit more of a challenge, as modifying fields takes more steps.

Thanks for the pointer though!

Marc
Alain CabonAlain Cabon
Hi Marc,

It is a question of expert and I didn't find the rule at the first try either.

I began by trying something with Apex metadata type "retrieve" and "deploy" (relatively new directly in Apex) with no success.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Metadata_Operations.htm#apex_class_Metadata_Operations

The documentation of Salesforce is never dated and (without the version 44, 45?) so that could be obsolete and there are perhaps workaround indeed (sfdx ?).

Alain