function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
alsinan nazimalsinan nazim 

Updating Custom Labels in Apex

Hi all,
I know we can access Custom Labels in Apex and VF.
But, Can we Update the value of a Custom Label through Apex Controller?


If So, How?

With Thanks.
Alex SelwynAlex Selwyn
No, you cannot update Custom Labels through normal apex controller.

You need metadata api to do that. you can use metadata api in apex here is an excellent article (https://andyinthecloud.com/2013/10/27/introduction-to-calling-the-metadata-api-from-apex/)

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm
SFDC coderSFDC coder
@alsinan nazim: No you cannot do that. If you want to update the values then do it from set up custom labels. Incase you want the value to change dynamically use custom setting and store the values in there and fetch them on certain conditions in Apex