Saturday, November 15, 2008

Assign Values to MS CRM attribute Types

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.

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;
 
 

No comments: