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!!




26 comments:

  1. 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
  2. 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
  3. 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
  4. This is good info. Any idea on how to insert/update Custom Label Translations?

    ReplyDelete
  5. 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
  6. Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. create your own bag

    ReplyDelete
  7. Those that are left in the middle will be good employees, who lack sparkle and energy but with some extra training and development could really make your company fly. Salesforce training in Hyderabad

    ReplyDelete
  8. A debt of gratitude is in order for such an extraordinary post and the audit, I am completely inspired! Keep stuff like this coming. get more info

    ReplyDelete
  9. Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. custom made patches

    ReplyDelete
  10. I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... custom made iron on patches

    ReplyDelete
  11. I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. Custom chenille patches

    ReplyDelete
  12. I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favorites blog site list and will be checking back soon. Please check out my site as well and let me know what you think. visto canadense

    ReplyDelete
  13. This is my first time visit here. From the tons of comments on your articles,I guess I am not only one having all the enjoyment right here! new zealand eta

    ReplyDelete
  14. A debt of gratitude is in order for the tips folks. They were all incredible. I have been having issues with being fat both rationally and physically. On account of you all I have been indicating enhancements. Do post more. SEO expert Singapore

    ReplyDelete
  15. Everything several evaluations about it and today I expected to see it again staggering how it is completely made. https://vograce.com

    ReplyDelete
  16. Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. visit this site

    ReplyDelete
  17. Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. nzeta

    ReplyDelete
  18. It was a very good post indeed. I thoroughly enjoyed reading it in my lunch time. Will surely come and visit this blog more often. Thanks for sharing. visit this site

    ReplyDelete
  19. What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. !!!

    Real Estate CRM

    ReplyDelete