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
Kenny JacobsonKenny Jacobson 

Custom Labels as Custom Global Variables

I have a client that is using Custom Labels as their own custom global variables (or "properties" or "name/value pairs" whatever you want to call them).  I'm just wondering if this is a common practice?  Are there any drawbacks?  It seems pretty ingenious to me, I had just never seen it before.

Here is an example of what I'm talking about:

Create a new Custom Label with Name = "Global_PublicKey" and Value="1234xyz"

So in Apex you just reference the value as Label.Global_PublicKey

private boolean isAuthorized(){
        String qPublickKey = ApexPages.currentPage().getParameters().get('publicKey');
        return qPublickKey.contains(Label.Global_PublicKey);
}
In a VisualForce page you refence it {!$Label.Global_PublicKey}:
<apex:page sidebar="false" showHeader="false"  >
   <apex:pageBlock title="Test">
   Global Variable PublicKey = {!$Label.Global_PublicKey}
   </apex:pageBlock>
</apex:page>

Thoughts?
 


 

Suneel#8Suneel#8
I think you can make use of Custom Labels this way, if your application is not multi lingual and you are not using Custom Labels for translation