How to retrieve Attribute Display Name in Dynamics CRM using C#
To retrieve the Label name of attributes which can give you the label of attribute if you pass it the schema name of entity, schema name of attribute and Iorganisation service object.
Class to include:
“using Microsoft.Xrm.Sdk.Messages;”
public static string RetrieveAttributeDisplayName(string EntitySchemaName, string AttributeSchemaName, IOrganizationService service)
{
RetrieveAttributeRequest retrieveAttributeRequest = new RetrieveAttributeRequest
{
EntityLogicalName = EntitySchemaName,
LogicalName = AttributeSchemaName,
RetrieveAsIfPublished = true
};
RetrieveAttributeResponse retrieveAttributeResponse = (RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);
AttributeMetadata retrievedAttributeMetadata = (AttributeMetadata)retrieveAttributeResponse.AttributeMetadata;
return retrievedAttributeMetadata.DisplayName.UserLocalizedLabel.Label;
}
No comments:
Post a Comment