Share via


RetrieveAttributeRequest Class

Definition

Contains the data that is needed to retrieve attribute metadata.

public ref class RetrieveAttributeRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class RetrieveAttributeRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type RetrieveAttributeRequest = class
    inherit OrganizationRequest
Public NotInheritable Class RetrieveAttributeRequest
Inherits OrganizationRequest
Inheritance
RetrieveAttributeRequest
Attributes

Examples

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface instance.

The following RetrieveColumnDefinitionById and RetrieveColumnDefinitionByName static methods both return the definition for the Account.Name column.

/// <summary>
/// Retrieves a column definition by ID.
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void RetrieveColumnDefinitionById(IOrganizationService service)
{
    Guid metadataId = new("a1965545-44bc-4b7b-b1ae-93074d0e3f2a");

    RetrieveAttributeRequest request = new()
    {
        MetadataId = metadataId
    };

    var response = (RetrieveAttributeResponse)service.Execute(request);

    OutputStringColumnData(response.AttributeMetadata);
}

/// <summary>
/// Retrieves a column definition by name
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void RetrieveColumnDefinitionByName(IOrganizationService service) {
    string tableLogicalName = "account";
    string columnLogicalName = "name";

    RetrieveAttributeRequest request = new() { 
      EntityLogicalName = tableLogicalName,
      LogicalName = columnLogicalName
    };

    var response = (RetrieveAttributeResponse)service.Execute(request);

    OutputStringColumnData(response.AttributeMetadata);
}

// Writes details about string columns
static void OutputStringColumnData(AttributeMetadata attributeMetadata) {

    var columnDefinition = (StringAttributeMetadata)attributeMetadata;

    Console.WriteLine($"DisplayName:{columnDefinition.DisplayName.UserLocalizedLabel.Label}");
    Console.WriteLine($"MaxLength:{columnDefinition.MaxLength}");
}

Both RetrieveColumnDefinitionById and RetrieveColumnDefinitionByName static methods use the OutputStringColumnData method to write the following:

DisplayName:Account Name
MaxLength:160  

Sample code on GitHub

Work with attribute metadata

Remarks

Usage

Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of RetrieveAttributeResponse.

Privileges and Access Rights

Column schema information is available for all users.

Notes for Callers

You can use either the LogicalName or MetadataId properties to specify the column definition you want to retrieve.

Constructors

RetrieveAttributeRequest()

Initializes a new instance of the RetrieveAttributeRequest class.

Properties

ColumnNumber

Gets or sets a column number value to identify an attribute from the Audit.AttributeMask column Optional.

EntityLogicalName

Gets or sets the logical name of the table that contains the attribute. Optional.

ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
LogicalName

Gets or sets the logical name of the column definition to be retrieved. Optional.

MetadataId

The unique identifier for the attribute. Optional.

Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RequestId

Gets or sets the ID of the request. Optional.

(Inherited from OrganizationRequest)
RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RetrieveAsIfPublished

Gets or sets whether to retrieve the metadata that has not been published. Required.

Applies to