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
Naresh Krishna.ax1176Naresh Krishna.ax1176 

Create Custom Labels from apex code

Hi All,

 

I need to create hundreds of custom labels.

 

I have these labels in properties file as below.

UserName=User Name

Password=Password

 

Can we create them using apex code or we need to create them one by one from App Setup -> Custom Labels -> New Custom Label ?

 

Could anyone please help me on this

 

Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
Jamz_2010Jamz_2010

Hi,

 

From what I understand you want to actually create the Custom Label within Apex.

 

E.g. insert new Label(Name='test', Value='test');

 

As far as I know this isn't possible directly from Apex - you would either need to create the Labels manually or use a Custom Setting...

 

James

All Answers

MagulanDuraipandianMagulanDuraipandian

https://sites.google.com/site/infallibletechie/how-to-use-custom-labels-in-visualforce-page-and-apex-class

 

Check this!!!

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution.

Naresh Krishna.ax1176Naresh Krishna.ax1176

I have an idea on how to create custom labels manually but am asking for through apex code how can we achieve this.

Thanks.

MagulanDuraipandianMagulanDuraipandian

Check this

 

https://sites.google.com/site/infallibletechie/dynamic-creation-of-outputlabel

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution.

Jamz_2010Jamz_2010

Hi,

 

From what I understand you want to actually create the Custom Label within Apex.

 

E.g. insert new Label(Name='test', Value='test');

 

As far as I know this isn't possible directly from Apex - you would either need to create the Labels manually or use a Custom Setting...

 

James

This was selected as the best answer