You need to sign in to do that
Don't have an account?
How to query the records from custom label object?
Hi Friends,
I need to know how to the query the records from custom label object. Is it possible to query the data from this object? As we do the same from other objects like Account, Contact, ......
We can use labels in our controller, like Label.<Label_Name>.
while i am trying to query the data from customLabel, it is throwing error like :
"line 1, column 20: sObject type 'CustomLabel' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names."
Please help me in this, how to use this object in apex controller.
Thanks in advance.
Regards,
Phanikumar
Hi,
Please refer below blog,
http://th3silverlining.com/2009/06/10/dynamic-custom-labels/
Hope this helps :)
Thanks,
Devendra
For getting the custom label in apex class use Label.<label_name>
for example:
Msg : string variable
Invalid_Usertrest: name of the label.
Msg = Label.Invalid_Usertrest
Kindly let me know if it helps.
Can you share code where you are getting error?
Also if you want to retrieve value from custom label use: Label<Label_Name>
Thanks
Custom labels are not accessible via SOQL. You will need to use the Metadata API to complete the query you are looking for.
I would suggest taking a look at Andrew Fawcett's Apex Wrapper Salesforce Metadata API.(https://github.com/financialforcedev/apex-mdapi).
With the API you can query the CustomLabels metadata type to get the information you are looking for.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha
Select id, name, value from CustomLabel where value like '%Please attach your%' limit 5
-- enable Use Tooling API in query editor