Created
April 16, 2021 08:20
-
-
Save mhamzas/98555fcde33fd6ee7d4559f31768b33b to your computer and use it in GitHub Desktop.
Get Object and Field Label value using API Names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void getLabelsfromAPINames(String ObjectApi, String FieldApi){ | |
| if(!String.IsBlank(ObjectApi) && !String.IsBlank(FieldApi)){ | |
| system.debug('Object : '+(String)Schema.getGlobalDescribe().get(ObjectApi).getDescribe().getLabel()+', Field : '+ (String)Schema.getGlobalDescribe().get(ObjectApi).getDescribe().fields.getMap().get(FieldApi).getDescribe().getLabel()+' \n'; | |
| } | |
| } | |
| // Usage | |
| getLabelsfromAPINames('Account', 'Name'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment