Export (0) Print
Expand All

Using CRM Attribute Types

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Microsoft Dynamics CRM contains a set of attribute type classes used to define the attributes for each entity. These classes are specified in the following table.

Class nameDescription
CrmBooleanUsed for attributes of type Boolean.
CrmDateTimeUsed for attributes of type date/time.
CrmDecimalUsed for attributes of type decimal.
CrmFloatUsed for attributes of type float.
CrmMoneyUsed for attributes of type money.
CrmNumberUsed for attributes of type number or integer.
CrmReferenceUsed for attributes that refer to another entity. You must set both the type and Value fields when you set an attribute of this type.
CustomerUsed for attributes that refer to a customer. This type is a subclass of the CrmReference class.
EntityNameReferenceUsed for attributes that refer to the entity name.
KeyUsed for attributes that represent a primary key.
LookupUsed for attributes that refer to another entity. This type is a subclass of the CrmReference class.
OwnerUsed for attributes that refer to the owner of an entity. This type is a subclass of the CrmReference class.
PicklistUsed for attributes of type picklist.
EntityNameStateInfoUsed for attributes of type state, where EntityName is the name of the entity in camel case.
StatusUsed for attributes of type status.
StringUsed for attributes of type text (ntext) or memo (nvarchar).
UniqueIdentifierUsed for attributes that represent a GUID.

Examples

The following sample shows you how to instantiate and set the value of each data type.

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = ""http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

CrmBoolean boolean = new CrmBoolean();
boolean.Value = true;

CrmDateTime dateTime = new CrmDateTime();
dateTime.Value = "2006/5/27T17:00:00";

CrmDecimal dec = new CrmDecimal();
dec.Value = (decimal)10.1;

CrmFloat f = new CrmFloat();
f.Value = (float)10.1;

CrmMoney money = new CrmMoney();
money.Value = (decimal)10.00;

CrmNumber number = new CrmNumber();
number.Value = 10;

Lookup lookup = new Lookup();
lookup.Value = user.UserId;
lookup.type = EntityName.systemuser.ToString();

Owner owner = new Owner();
owner.type = EntityName.systemuser.ToString();
owner.Value = user.UserId;

Picklist list = new Picklist();
list.Value = 1;

Status status = new Status();
status.Value = 1;

EntityNameReference reference = new EntityNameReference();
reference.Value = EntityName.systemuser.ToString();

Key key = new Key();
key.Value = user.UserId;

See Also

Concepts


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft