Wednesday, July 4, 2018

Create Update Custom Label by Using Metadata API

We usually update custom labels from UI. After sandbox refresh, we update all custom labels so that these don't point to production URLs or values.

By using Metadata API, we can write automated apex script through which we can update all custom labels.

You can either download Metadata API WSDL from Salesforce and generate apex class by clicking on Generate from WSDL button.


Or you can download the MetadataService class from below link:

MetadataService.cls

I have created 2 separate static methods, one for creating new custom label and another for updating existing custom label. Below is class code:


Now by running below code in execute anonymous in developer console, you can create custom label:

MetadataAPIUtility.createCustomLabel('SFDC_Blog_URL','My test label from metadata api','en_US','http://www.sfdcstuff.com/',false);



You have to specify custom label values as a parameters in static method.

In order to update custom label, execute below code:

MetadataAPIUtility.updateCustomLabel('SFDC_Blog_URL','My test label from metadata api','en_US','https://www.sfdcstuff.com/search/label/Lightning',false);



Hope this will help!!




20 comments:

  1. Replies
    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important. Project Center in Chennai It’s what organizations do with the data that matters. Big data can be analyzed for insights that lead to better decisions and strategic business moves.

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.
      Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai


      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Always so interesting to visit your site.What a great info, thank you for sharing. this will help me so much in my learning Custom Made Patches

    ReplyDelete
  3. This concept is a good way to enhance the knowledge.thanks for sharing. please keep it up salesforce Online Training Bangalore

    ReplyDelete
  4. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...

    payrollmanagementservice
    Article submission sites

    ReplyDelete
  5. I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up. relojes personalizados con foto

    ReplyDelete
  6. Hey! great post you shared. It was amazing to read whole new update also want to add more about custom lables here for you. It is good to know about new things.

    ReplyDelete
  7. This is good info. Any idea on how to insert/update Custom Label Translations?

    ReplyDelete
  8. Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. custom embroidered patches

    ReplyDelete