I'am working on post deployment automation process in salesforce. I am stuck on how should I update values in custom labels which needs tobe updated manually after a sandbox refresh.
1 Answer
You can use this MetadataService class and follow this example:
public static void updateField()
{
MetadataService.MetadataPort service = createService();
MetadataService.CustomField customField = new MetadataService.CustomField();
customField.fullName = 'Test__c.TestField__c';
customField.label='New Test Field Label';
customField.type_x = 'Text';
customField.length = 52;
List<MetadataService.SaveResult> results =
service.updateMetadata(
new MetadataService.Metadata[] { customField });
handleSaveResults(results[0]);
}
In your case, you will probably want to use only the fullName
and label
attributes. Type and length are not relevant for you to set here.
More on how to handle the save results can be viewed in the example class at line 1536.
-
1To use this code you will need to setup github.com/financialforcedev/apex-mdapi to make external HTTP calls to the Metadata SOAP Api Commented Dec 19, 2018 at 23:51