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
dev_forcedev_force 

Custom Labels - used as configuration parameters?

Are there any reasons why Custom Labels can't be used as configuration paramters in apex classes/triggers?

 

 

For example,

 

String queryFields = System.Label.CustomQueryFieldsAccount;

 

List<Account> = Database.query("SELECT "+queryFields+"FROM Account);

Message Edited by dev_force on 03-27-2009 12:13 PM
mikefmikef

No reason not to use Labels. In fact this is a good way to set up your application, and get hard coding out of your code.

I use Labels for this kind of thing all the time.

 

I would check to see if your queryFields variable is set up correctly before you proceed with your query. Just as an extra step to safe guard the user experience.

ie. You could check to see if queryFields has all the correct comma placements, and if not throw a custom error message before the user would get a nasty query exception.

 

Labels can let the business tweak the behavior of our code without code changes.

 

Nice.