Udostępnij za pośrednictwem


Customize entity attribute metadata

 

Applies To: Dynamics CRM 2015

Use the AttributeMetadata class to retrieve existing attributes. This class is returned by the RetrieveAttributeRequest message. The AttributeMetadata class inherits from the abstract MetadataBase class.

Use the specific class for each attribute type with the CreateAttributeRequest message to update attributes or create custom attributes.

Note

You can access custom attributes programmatically after you create them, but you must add them to an entity form and publish them before users can see them.

Attribute types

The following table lists each type of Attribute you can work with. Each attribute inherits from the AttributeMetadata class.

Class

Application Label

Description

BooleanAttributeMetadata

Two Option

A Boolean attribute. You can specify the text for both options. When added to a form, the field properties control whether the attribute is displayed as two radio buttons, a check box, or a list.

DateTimeAttributeMetadata

Date and Time

A date and time attribute. You can specify the behavior to store date and time values with or without time zone information, and format to define the display format of the values. More information: Behavior and format of the date and time attribute

Note

If you are using Microsoft Dynamics CRM Online, and have updated to Microsoft Dynamics CRM Online 2015 Update 1, all date and time attributes now support values as early as 1/1/1753 12:00 AM.

DecimalAttributeMetadata

Decimal Number

A decimal attribute. You can specify the level of precision up to ten decimal places and the minimum and maximum values from -100,000,000,000 to 100,000,000,000.

DoubleAttributeMetadata

Floating Point Number

A double attribute. You can specify the level of precision up to five decimal places and the minimum and maximum values from -100,000,000,000 to 100,000,000,000.

Note

DoubleAttributeMetadata replaces the FloatAttributeMetadata used in Microsoft Dynamics CRM 4.0.

ImageAttributeMetadata

Image

An image attribute. Each entity can have one image attribute. Certain system entities have image attributes and new image attributes cannot be added to system entities that do not have them. You can add an image attribute to custom entities

All image attributes have the SchemaName ‘EntityImage’ and the LogicalName ‘entityimage’. Custom image attributes will not use the solution publisher customization prefix in the name. More information: Entity images.

IntegerAttributeMetadata

Whole Number

An integer attribute. You can specify the maximum and minimum values from -2,147,483,648 to 2,147,483,647.

This attribute can be formatted to create the following types of fields using the IntegerFormat enumeration:

  • Duration: Displays a drop-down list that contains time intervals. A user can select a value from the list or type an integer value that represents the number of minutes.

  • TimeZone: Displays a drop-down list that contains a list of time zones.

  • Language: Displays a drop-down list that contains a list of languages that have been enabled for the organization. If no other languages have been enabled, the base language will be the only option. The value saved is the LCID value for the language.

LookupAttributeMetadata

Lookup

An attribute created when an entity relationship is created by using the CreateOneToManyRequest message.

MemoAttributeMetadata

Multiple Lines of Text

A memo attribute. Displays as a text box field in a form. The maximum length is 1048576 characters.

MoneyAttributeMetadata

Currency

A money attribute. You can specify the maximum and minimum values between - 922,337,203,685,477 and 922,337,203,685,477.

The level of precision can be set by using the PrecisionSource property:

  • When the precision is set to zero (0), the MoneyAttributeMetadata.Precision value is used.

  • When the precision is set to one (1), the Organization.PricingDecimalPrecision value is used.

  • When the precision is set to two (2), the TransactionCurrency.CurrencyPrecision value is used.

PicklistAttributeMetadata

Options Set

A picklistattribute. This attribute provides a set of options that are displayed in a drop-down list. You can create the picklist attribute so that it can contain its own options or use a global options set.

StateAttributeMetadata

Status

The state attribute is created automatically when the entity is created.

Note

The options available for this attribute are read-only.

StatusAttributeMetadata

Status Reason

The status attribute is created automatically when the entity is created. Each of the options must be associated with the StateAttributeMetadata attribute for the entity. Use the InsertStatusValueRequest message to update options available for this attribute.

Note

Each StatusOption must reference a specific state attribute value because status values depend on a specific state value.

StringAttributeMetadata

Single Line of Text

See StringAttributeMetadata formats.

StringAttributeMetadata formats

String attributes can be formatted to allow links to initiate phone calls by using Lync or Skype. This change requires that a new FormatName property be added to the StringAttributeMetadata class and the deprecation of the Format property.

Note

Lync has been rebranded as Skype for Business. Currently, you’ll still see references to “Lync” in Microsoft Dynamics CRM, but CRM will work with Skype for Business.

Using the StringFormat enumeration to define the format for StringAttributeMetadata.Format is deprecated. Instead, use the StringFormatName class to set the value of StringAttributeMetadata.FormatName.

This allows for setting the format value of PhoneNumber, which does not exist in the StringFormat enumeration.

For backwards compatibility, you can set a value to control how the attribute is formatted by using either the Format or FormatName property. Your existing code will continue to work if you only use Format, but you will not be able to format an attribute as a phone number without using FormatName. If both properties are set, the value set using FormatName is the one that will be applied.

The StringFormatName class contains the following members; each member returns a string with the same value as the member name:

Member name and value

Description

Email

The form field will validate the text value as an e-mail address and create a mailto link in the field.

PhoneNumber

The form field will contain a link to initiate a phone call by using Lync or Skype.

PhoneticGuide

For internal use only.

Text

The form will display a text box.

TextArea

The form will display a text area field.

TickerSymbol

The form will display a link that will open to display a quote for the stock ticker symbol.

URL

The form will display a link to open the URL.

VersionNumber

For internal use only.

See Also

Extend the metadata model
Work with attribute metadata
Behavior and format of the date and time attribute
Entity attribute metadata messages
Sample: Work with attribute metadata
Technical Article: Using Option Set Options with the REST Endpoint - JScript
Sample: Dump attribute metadata to a file
Sample: Dump attribute picklist metadata to a file
Sample: Convert date and time behavior

© 2016 Microsoft. All rights reserved. Copyright