Hi Developers, Welcome again! In this post we are going to learn how we can create/update custom metadata using apex class.
As we know that it is not similar to create/update metadata using apex like Custom Setting OR Custom/Standard Object.
To create/update Custom Metadata we need to deploy the custom metadata using DeployCallback interface and it’s required methods.
So, let’s start doing the development. You need to follow the below simple steps.
Step 1 – Create Custom Metadata
Navigate to Setup -> Develop -> Custom Metadata Types -> New Custom Metadata Types -> Create the Custom Metadata. I have created label as Profile Setting. Refer below Screenshot

Step 2 – Create a class and implement Metadata.DeployCallback interface
public class CreateUpdateMetadataUtils implements Metadata.DeployCallback {
}
Step 3 – implement handleResult method in the class
After you have implemented the DeployCallback interface you need to provide the implementation of handleResult method. Below is the code for the same
public class CreateUpdateMetadataUtils implements Metadata.DeployCallback {
/* Below method recieves the 2 parameters
1 - Metadata.DeployResult => Object of MetadataContainer class where this method has been implemented.
2 - Metadata.DeployCallbackContext => Object of the class where this method has been implemented
*/
public void handleResult(Metadata.DeployResult result,
Metadata.DeployCallbackContext context) {
if (result.status == Metadata.DeployStatus.Succeeded) {
// Deployment was successful
} else {
// Deployment was not successful
}
}
}
Step 4 – Prepare the Custom Metadata
Now, as you have done the above step now time is to prepare the custom Metadata for this create the Object of Metadata.CustomMetadata like below
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
customMetadata.fullName = 'Profile_Setting.Admin';
customMetadata.label = 'Admin';
Value for fullName of Metadata we need to provide the Qualified Name. For example, if the object name of Metadata is Profile_Setting then and you wanted to create a record named Admin then the full name will look like ‘Profile_Setting.Admin‘
Point to keep in mind
Step 5 – Add field values to the Metadata Record
We have create the Object of Custom Metadata and then also provided the fullName(MasterLabel). Now, use the below code to provide the value for the custom fields. Below is the Code
/* Create the Object of CustomMetadataValue */
Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
/* Provide the API Name of the Field like Admin__c */
customField.field = 'Profile_Full_Name__c';
/* Provide the value for the field */
customField.value = 'Admin';
/* Add this field to the Metadata That we created */
customMetadata.values.add(customField);
/* If you wanted to add more than one field you need to repeat the above step OR You can use Map<String, Object> where Key is the Field API Name and value is the value for the field */
/* In my example, I will create a separate method which is responsible for deploying the Custom Metadata Record */
See the code comments.
Step 6 – Create a Deploy Container
Till now we have performed the below steps
- Create Custom Metadata
- Create a Class that implements Metadata.DeployCallback interface
- Implement the handleResult method
- Prepare the Custom Metadata with the fullName (MasterLabel)
- Add values to the Custom Metadata
Let’s create a deploy container which will be responsible for deploying the Custom Metadata Record. Create the DeployContainer class Object
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
Add the Custom Metadata in the DeployContainer using addMetadata method
mdContainer.addMetadata(customMetadata);
Step 7 – Deploy the Custom Metadata
Use below code to deploy the custom metadata that we have prepared above
1 – Create the Object of our class
CreateUpdateMetadataUtils callback = new CreateUpdateMetadataUtils();
2 – Deploy the metadata using below code
Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, callback);
Here is the Final and Complete Class
public class CreateUpdateMetadataUtils implements Metadata.DeployCallback {
public void handleResult(Metadata.DeployResult result, Metadata.DeployCallbackContext context) {
if (result.status == Metadata.DeployStatus.Succeeded) {
System.debug(' success : '+ result);
} else {
System.debug(' fail : '+ result);
}
}
public static void createUpdateMetadata(String fullName, String label, Map<String, Object> fieldWithValuesMap){
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
customMetadata.fullName = fullName;
customMetadata.label = label;
for(String key : fieldWithValuesMap.keySet()){
Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
customField.field = key;
customField.value = fieldWithValuesMap.get(key);
customMetadata.values.add(customField);
}
Metadata.DeployContainer mdContainer = new Metadata.DeployContainer();
mdContainer.addMetadata(customMetadata);
CreateUpdateMetadataUtils callback = new CreateUpdateMetadataUtils();
Id jobId = Metadata.Operations.enqueueDeployment(mdContainer, callback);
}
}
Test the code
Run the below code from Developer Console
Map<String, Object> maptest = new Map<String, Object>();
maptest.put('Is_Admin__c',true);
maptest.put('Profile_Full_Name__c','Admin');
maptest.put('Profile_Name__c','Admin');
maptest.put('Updated__c',false);
CreateUpdateMetadataUtils.createUpdateMetadata('Profile_Setting.TEST_AMIT','TEST_AMIT',maptest);
Go to Setup -> Deploy -> Deployment Status -> and check if you are getting success message or NOT

Navigate to the custom metadata and then make sure that metadata has been created or not.

Here is the test class for the same.
@IsTest
public class CreateUpdateMetadataUtilsTest {
@IsTest
public static void configSetupTest(){
String fullName = 'Profile_Setting.StripeConfig';
String label = 'TEST_AMIT';
String values = '{'+
' "Is_Admin__c": "true",'+
' "Profile_Full_Name__c": "DEMO_SECRET",'+
' "Profile_Name__c":"DEMO_NAME",'+
' "Updated__c" : "false"'+
'}';
Map<String, Object> deployedValue = (Map<String, Object>)JSON.deserializeUntyped(values);
Test.startTest();
CreateUpdateMetadataUtils.createUpdateMetadata(fullName, label, deployedValue);
Test.stopTest();
}
@IsTest
public static void CreateUpdateMetadataUtilsTest(){
CreateUpdateMetadataUtils metadata = new CreateUpdateMetadataUtils();
Test.startTest();
metadata.handleResult(new Metadata.DeployResult(), new Metadata.DeployCallbackContext());
Test.stopTest();
}
}
#Salesforce #SFDCPanther #DeveloperGeeks
Hi Amit,
I have a question from step 4 onward,
I mean do we need to execute the code in an isolated way in dev console.
I am a bit confused.
Regards,
Siddhartha
Hi Siddhartha,
The Code that I am using in Anonymous Window is just for testing Purpose. You can call the method from Apex Class As well. But the Parameters must be of the same DataType because this code is for generic metadata that means you can use this code for creating any metadata records.
What I meant was shall we proceed from step 4 in Execute Anonymous COde window.
Hi Amit,
Thank you for the clear explanation!
I ran this code, but don’t see any result.
Maybe it because I have a free developer account?
Here is my log:
45.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;NBA,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
08:11:30.34 (34107709)|USER_INFO|[EXTERNAL]|0054J000000vzkk||(GMT+01:00) Greenwich Mean Time (Europe/Dublin)|GMT+01:00
08:11:30.34 (34278345)|EXECUTION_STARTED
08:11:30.34 (34293422)|CODE_UNIT_STARTED|[EXTERNAL]|DeployWorker.enqueueApexCallback
08:11:30.34 (42528076)|HEAP_ALLOCATE|[72]|Bytes:3
08:11:30.34 (42713894)|HEAP_ALLOCATE|[77]|Bytes:152
08:11:30.34 (42744856)|HEAP_ALLOCATE|[342]|Bytes:408
08:11:30.34 (42789823)|HEAP_ALLOCATE|[355]|Bytes:408
08:11:30.34 (42810224)|HEAP_ALLOCATE|[467]|Bytes:48
08:11:30.34 (42920776)|HEAP_ALLOCATE|[139]|Bytes:6
08:11:30.34 (42951473)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:552
08:11:30.34 (43021331)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:68
08:11:30.34 (43113163)|SYSTEM_METHOD_ENTRY|[2]|DeployResult.DeployResult()
08:11:30.34 (43154492)|STATEMENT_EXECUTE|[2]
08:11:30.34 (43224544)|SYSTEM_METHOD_EXIT|[2]|DeployResult
08:11:30.34 (55291093)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (55339884)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (55820141)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.id|”0Af4J00000FqesASAR”|0x78e908ab
08:11:30.34 (55925653)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:15
08:11:30.34 (55942250)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (55994577)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.canceledBy|”000000000000000″|0x78e908ab
08:11:30.34 (56669706)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (56719433)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.canceledByName|null|0x78e908ab
08:11:30.34 (56853642)|HEAP_ALLOCATE|[50]|Bytes:5
08:11:30.34 (56894877)|HEAP_ALLOCATE|[56]|Bytes:5
08:11:30.34 (56911997)|HEAP_ALLOCATE|[64]|Bytes:7
08:11:30.34 (56936537)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (56946082)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (56979132)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.checkOnly|false|0x78e908ab
08:11:30.34 (57204445)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (57217384)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (57290246)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.completedDate|”2019-05-26T07:11:31.000Z”|0x78e908ab
08:11:30.34 (57324429)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:15
08:11:30.34 (57346383)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (57368225)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.createdBy|”0054J000000vzkk”|0x78e908ab
08:11:30.34 (67049917)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:19
08:11:30.34 (67083647)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (67172841)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.createdByName|””|0x78e908ab
08:11:30.34 (67246867)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (67257491)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (67306616)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.createdDate|”2019-05-26T07:11:30.000Z”|0x78e908ab
08:11:30.34 (67370125)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:136
08:11:30.34 (67430216)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (67539123)|SYSTEM_METHOD_ENTRY|[3]|DeployDetails.DeployDetails()
08:11:30.34 (67551483)|STATEMENT_EXECUTE|[3]
08:11:30.34 (67590403)|SYSTEM_METHOD_EXIT|[3]|DeployDetails
08:11:30.34 (67816706)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (67835706)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (67844783)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (68091282)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:332
08:11:30.34 (68151821)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:38
08:11:30.34 (68191369)|SYSTEM_METHOD_ENTRY|[2]|DeployMessage.DeployMessage()
08:11:30.34 (68200836)|STATEMENT_EXECUTE|[2]
08:11:30.34 (68218117)|SYSTEM_METHOD_EXIT|[2]|DeployMessage
08:11:30.34 (68672711)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (68697115)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (68732582)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.changed|false|0x68e2f535
08:11:30.34 (68761561)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (68781518)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.columnNumber|null|0x68e2f535
08:11:30.34 (68804928)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:14
08:11:30.34 (68813089)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (68833354)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.componentType|”CustomMetadata”|0x68e2f535
08:11:30.34 (68858094)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (68864847)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (68882702)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.created|false|0x68e2f535
08:11:30.34 (68905681)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (68913919)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (68950400)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.createdDate|”2019-05-26T07:11:30.925Z”|0x68e2f535
08:11:30.34 (68975876)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (68984373)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69001618)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.deleted|false|0x68e2f535
08:11:30.34 (69062842)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:43
08:11:30.34 (69110441)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69136700)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.fileName|”customMetadata/Profi (23 more) …”|0x68e2f535
08:11:30.34 (69161895)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:25
08:11:30.34 (69167695)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69190054)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.fullName|”Profile_Setting.TEST (5 more) …”|0x68e2f535
08:11:30.34 (69352956)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69374415)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.id|null|0x68e2f535
08:11:30.34 (69400367)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69418714)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.lineNumber|null|0x68e2f535
08:11:30.34 (69439711)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:107
08:11:30.34 (69447569)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69469289)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.problem|”Profile_Setting__mdt (87 more) …”|0x68e2f535
08:11:30.34 (69492317)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
08:11:30.34 (69498075)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69510841)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.problemType|0x574894ed|0x68e2f535
08:11:30.34 (69534607)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (69541909)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69559598)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.success|false|0x68e2f535
08:11:30.34 (69681284)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (69700517)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (69746798)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (69756043)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69781997)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.changed|true|0x78871517
08:11:30.34 (69797954)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69815777)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.columnNumber|null|0x78871517
08:11:30.34 (69831852)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69847262)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.componentType|null|0x78871517
08:11:30.34 (69863177)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (69870216)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69890956)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.created|false|0x78871517
08:11:30.34 (69909951)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69915514)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69945195)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.createdDate|”2019-05-26T07:11:30.935Z”|0x78871517
08:11:30.34 (69962588)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (69969791)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (69986241)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.deleted|false|0x78871517
08:11:30.34 (70002294)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:11
08:11:30.34 (70012878)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (70031594)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.fileName|”package.xml”|0x78871517
08:11:30.34 (70045837)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:11
08:11:30.34 (70053285)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (70071190)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.fullName|”package.xml”|0x78871517
08:11:30.34 (70085817)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (70101261)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.id|null|0x78871517
08:11:30.34 (70115408)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (70130783)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.lineNumber|null|0x78871517
08:11:30.34 (70146727)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (70162541)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.problem|null|0x78871517
08:11:30.34 (70179737)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (70195382)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.problemType|null|0x78871517
08:11:30.34 (70211070)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (70218258)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (70235092)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.success|true|0x78871517
08:11:30.34 (70247583)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (70253358)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (70317327)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:11:30.34 (70343061)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
08:11:30.34 (70528339)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.componentFailures|[{“changed”:false,”componentType”:”CustomMetadata”,”created”:false,”createdDate”:”2019-05-26T07:11:30.925Z”,”deleted”:false,”fileName”:”customMetadata/Profi (23 more) …”,”fullName”:”Profile_Setting.TEST (5 more) …”,”problem”:”Profile_Setting__mdt (87 more) …”,”problemType”:”0x574894ed”,”success”:false}]|0x14ca6dfc
08:11:30.34 (70586949)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:11:30.34 (70597253)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
08:11:30.34 (70678789)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.componentSuccesses|[{“changed”:true,”created”:false,”createdDate”:”2019-05-26T07:11:30.935Z”,”deleted”:false,”fileName”:”package.xml”,”fullName”:”package.xml”,”success”:true}]|0x14ca6dfc
08:11:30.34 (70716566)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
08:11:30.34 (70725259)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72299784)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.messages|[{“changed”:false,”componentType”:”CustomMetadata”,”created”:false,”createdDate”:”2019-05-26T07:11:30.925Z”,”deleted”:false,”fileName”:”customMetadata/Profi (23 more) …”,”fullName”:”Profile_Setting.TEST (5 more) …”,”problem”:”Profile_Setting__mdt (87 more) …”,”problemType”:”0x574894ed”,”success”:false},{“changed”:true,”created”:false,”createdDate”:”2019-05-26T07:11:30.935Z”,”deleted”:false,”fileName”:”package.xml”,”fullName”:”package.xml”,”success”:true}]|0x78e908ab
08:11:30.34 (72407738)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
08:11:30.34 (72471339)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72506008)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.details|0x14ca6dfc|0x78e908ab
08:11:30.34 (72555526)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (72565548)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72600083)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.done|true|0x78e908ab
08:11:30.34 (72628116)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72653708)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.errorMessage|null|0x78e908ab
08:11:30.34 (72678430)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72702057)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.errorStatusCode|null|0x78e908ab
08:11:30.34 (72734052)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (72743354)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72762704)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.ignoreWarnings|false|0x78e908ab
08:11:30.34 (72791163)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (72801543)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72830343)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.lastModifiedDate|”2019-05-26T07:11:31.000Z”|0x78e908ab
08:11:30.34 (72858592)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:11:30.34 (72865927)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72891464)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.numberComponentErrors|1|0x78e908ab
08:11:30.34 (72910092)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:11:30.34 (72917272)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72938121)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.numberComponentsDeployed|0|0x78e908ab
08:11:30.34 (72955239)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
08:11:30.34 (72962481)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (72979183)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.numberComponentsTotal|1|0x78e908ab
08:11:30.34 (72999752)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (73006889)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (73024332)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.rollbackOnError|true|0x78e908ab
08:11:30.34 (73046811)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:56
08:11:30.34 (73053618)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (73076546)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.startDate|”2019-05-26T07:11:30.000Z”|0x78e908ab
08:11:30.34 (73095803)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (73112566)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.stateDetail|null|0x78e908ab
08:11:30.34 (73131948)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
08:11:30.34 (73139164)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (73155078)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.status|0x6b7e690d|0x78e908ab
08:11:30.34 (73175542)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (73183144)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (73199846)|VARIABLE_ASSIGNMENT|[EXTERNAL]|this.success|false|0x78e908ab
08:11:30.34 (73639377)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:5
08:11:30.34 (73722541)|SYSTEM_METHOD_ENTRY|[8]|DeployCallbackQueueable.DeployCallbackQueueable()
08:11:30.34 (73735823)|STATEMENT_EXECUTE|[8]
08:11:30.34 (73757367)|SYSTEM_METHOD_EXIT|[8]|DeployCallbackQueueable
08:11:30.34 (73776273)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:12
08:11:30.34 (73786438)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (73794409)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:3
08:11:30.34 (73814407)|METHOD_ENTRY|[1]|01p4J000008ljBX|CreateUpdateMetadataUtils.CreateUpdateMetadataUtils()
08:11:30.34 (73829123)|STATEMENT_EXECUTE|[1]
08:11:30.34 (73854360)|STATEMENT_EXECUTE|[1]
08:11:30.34 (73860901)|METHOD_EXIT|[1]|CreateUpdateMetadataUtils
08:11:30.34 (73873218)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
08:11:30.34 (73880833)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:96
08:11:30.34 (73954687)|VARIABLE_SCOPE_BEGIN|[16]|this|Metadata.DeployCallbackQueueable|true|false
08:11:30.34 (74093585)|VARIABLE_ASSIGNMENT|[16]|this|{}|0x67a1ed58
08:11:30.34 (74114116)|VARIABLE_SCOPE_BEGIN|[16]|callback|Metadata.DeployCallback|true|false
08:11:30.34 (74148773)|VARIABLE_ASSIGNMENT|[16]|callback|{}|0xcf3a730
08:11:30.34 (74166045)|VARIABLE_SCOPE_BEGIN|[16]|result|Metadata.DeployResult|true|false
08:11:30.34 (74825409)|VARIABLE_ASSIGNMENT|[16]|result|{“canceledBy”:”000000000000000″,”checkOnly”:false,”completedDate”:”2019-05-26T07:11:31Z”,”createdBy”:”0054J000000vzkk”,”createdByName”:””,”createdDate”:”2019-05-26T07:11:30Z”,”details”:”0x14ca6dfc”,”done”:true,”id”:”0Af4J00000FqesASAR”,”ignoreWarnings”:false,”lastModifiedDate”:”2019-05-26T07:11:31Z”,”messages”:”0x5b1f3fc5″,”numberComponentErrors”:1,”numberComponentsDeployed”:0,”numberComponentsTotal”:1,”rollbackOnError”:true,”startDate”:”2019-05-26T07:11:30Z”,”status”:”0x6b7e690d”,”success”:false}|0x78e908ab
08:11:30.34 (98910844)|CODE_UNIT_FINISHED|DeployWorker.enqueueApexCallback
08:11:30.34 (99671137)|EXECUTION_FINISHED
Thank you!
Have you checked if the Metadata Record has been created or not? In the debug it is clear that the Deployment has been queued.
You can go to setup -> deployment status -> there you can check the status 🙂
Hi,
Yes, I checked!
the deploy was succeeded (saw it in deployment status), but the Metadata record didn’t created 🙁
What can make it?
Thank you!
Hi,
Yes, I checked!
the deploy was succeeded (saw it in deployment status), but the Metadata record didn’t created 🙁
What can make it?
Thank you!
How to get the Deployment status of deployed Custom Metadata, either success or if it has errors or if it has any issue while deploying .
Have you checked below method? In this method, it clearly states about success and error
public void handleResult(Metadata.DeployResult result,
Metadata.DeployCallbackContext context) {
if (result.status == Metadata.DeployStatus.Succeeded) {
// Deployment was successful
} else {
// Deployment was not successful
}
}
perfect explanation and working code
Thanks
is there any method to delete the metadata through apex
I have not found such a method. I need to check
Hello, this is really fab – thanks so much for jotting it all down. It works beautifully. Did you ever happen to put together a unit test class for this? Asking for a friend 🙂
Hi Louis,
Here is the code for the same. In the below code you need to use your Custom Metadata Name instead of that are there in the code.
@IsTest
public class StripeConfigurationServiceTest {
}
can we call this deploy container class by process builder
Yes. You can call but for that, you need to make some modifications in the Apex Class.