Created
May 26, 2020 15:32
-
-
Save tugce/51db700d921367744ee37dd25cba39e4 to your computer and use it in GitHub Desktop.
Apex script to create one metadata group called All Metadata with all metadata types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copado__Metadata_Group__c allMetadata = new copado__Metadata_Group__c (); | |
allMetadata.Name = 'All Metadata Types'; | |
insert allMetadata; | |
List<copado__Metadata_Group_Item__c> items = new List<copado__Metadata_Group_Item__c>(); | |
Schema.DescribeFieldResult typeResult = copado__Metadata_Group_Item__c.copado__Type__c.getDescribe(); | |
List<Schema.PicklistEntry> ple = typeResult.getPicklistValues(); | |
for( Schema.PicklistEntry f : ple) { | |
copado__Metadata_Group_Item__c item = new copado__Metadata_Group_Item__c(); | |
item.copado__Type__c = f.getValue(); | |
item.copado__Metadata_Group__c = allMetadata.Id; | |
item.copado__Operator__c = 'All'; | |
items.add(item); | |
} | |
insert items; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment