this function used to return label for field.
can be used for plugin,audit etc...
public static string GetColumnLabel(IPluginExecutionContext context, string entityTypeName, string columnName)
{
IMetadataService metadataService = context.CreateMetadataService(false);
Microsoft.Crm.SdkTypeProxy.Metadata.RetrieveAttributeRequest request = new Microsoft.Crm.SdkTypeProxy.Metadata.RetrieveAttributeRequest();
request.EntityLogicalName = entityTypeName;
request.LogicalName = columnName.ToLower();
Microsoft.Crm.SdkTypeProxy.Metadata.RetrieveAttributeResponse response = (Microsoft.Crm.SdkTypeProxy.Metadata.RetrieveAttributeResponse)metadataService.Execute(request);
AttributeMetadata am = response.AttributeMetadata;
if (am != null)
return am.DisplayName.UserLocLabel.Label;
return "";
}
Enjoy,
Rami Heleg