You need to sign in to do that
Don't have an account?
VSK98
How to insert the custom meta datatype in test class
Hi All,
I am using custom metadata type in Apex class. I am trying to insert the custom metadata type like custom object but I am getting an error. the fields are not editable.
In Apex Class:
Adv thanks,
VSK98
I am using custom metadata type in Apex class. I am trying to insert the custom metadata type like custom object but I am getting an error. the fields are not editable.
In Apex Class:
Roles__mdt roles = [SELECT id,Name from Roles__mdt where Name__c = 'xxxx' AND Isactive__c = true]
Adv thanks,
VSK98
No need to create test records for MetaData,
Thank You,
Rajesh Adiga P.
It is not possible to insert test custom metadata, unless you use the Metadata API which would also present a challenge in a test scenario. That said, you should not need to. Custom Metadata is Metadata and as such is not affected by the SeeAllData annotation. See this article dedicated to testing custom metadata.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha