Skip to content

Instantly share code, notes, and snippets.

@mhamzas
Created April 16, 2021 08:20
Show Gist options
  • Select an option

  • Save mhamzas/98555fcde33fd6ee7d4559f31768b33b to your computer and use it in GitHub Desktop.

Select an option

Save mhamzas/98555fcde33fd6ee7d4559f31768b33b to your computer and use it in GitHub Desktop.
Get Object and Field Label value using API Names
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