15

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.

2
  • 1
    Why closed? A concrete answer can be given that objectively answers the question.
    – Brian Low
    Commented Aug 8, 2018 at 20:59
  • 2
    A question with 7 upvotes and a concrete answer gets closed :( Commented Nov 7, 2018 at 19:33

1 Answer 1

8

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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .