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.
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.
Attribution
Source : Link , Question Author : AJINKYA RAUT , Answer Author : Renato Oliveira