So I'll try to keep this short and simple. I have a client who wants to use Custom Labels in their buttons so the average user can duplicate and re-use them.

One such label is simply the API name of a custom object, so to use it in the button logic I do something like var = {!$Label.cusLab} and the variable comes out like CustomObject__c.

However, say I wanted info about that object? If I type {!CustomObject__c.Id} it will return the id. You obviously can't do {!{!$Label.cusLab}.Id} because of syntax, but if you type {!$Label.cusLab+'.Id'} it returns the string 'CustomObject__c.Id' instead of actually returning the Id.

Any ideas on how I would use the custom label inside of an expression to return the correct info? I feel like it's possible and it's just a syntax thing I don't know enough about.

Any help would be appreciated. Thanks!

1 Answer 1


If you do {!$Label.cusLab} you get "CustomObject__c", but that's only because you've created the string "CustomObject__c" as a custom label. There is no relationship between that custom label and the actual custom object info. So you won't be able to fetch custom object info via the custom label approach.

If you want to display object metadata in visualforce or javascript, you need to fetch it via the metadata API. But this data cannot be fetched directly from Visualforce/javascript. You will need to create methods in an APEX controller that fetch the metadata via the metadata API, as e.g. described here: http://blog.jeffdouglas.com/2011/10/20/getting-salesforce-field-metadata-the-easy-way/

Then you need to expose the metadata via get methods in the APEX class, so you can access them from visualforce or javascript (basically in the same way as you fetch the custom labels).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .