Показаны сообщения с ярлыком SDK. Показать все сообщения
Показаны сообщения с ярлыком SDK. Показать все сообщения

2009-06-09

TargetUpdate VS Update method

If you have a question what is better for use: UpdateRequest with TargetUpdate or Update method, then first of all you must to look at MS CRM SDK "CrmService Common Methods" article.

There was said:
"The CrmService Web service provides a set of methods used to perform the most common operations on system and custom entities. These operations can also be performed by using the Execute method and the corresponding message. However, the methods will perform faster so they should be used whenever possible."

So service.Update is a winner.

2009-04-10

Null Values - based on MS CRM SDK

From Microsoft CRM SDK :

When you update an entity instance there is a mechanism you can use to differentiate the absence of a value from a null value. To set an attribute value to null you must set both IsNull and IsNullSpecified to true. For attributes of type String, you must assign the value to String.Empty. This same mechanism is used when you create a query to find a null value.

Another option is to use the type helper code available in Microsoft.Crm.Sdk assembly and in the CRMHelpers classes.

Example
The following code example shows you how to create null instances of the various Microsoft Dynamics CRM attribute types.

CrmBoolean boolean = new CrmBoolean();
boolean.IsNull = true;
boolean.IsNullSpecified = true;

CrmDecimal dec = new CrmDecimal();
dec.IsNull = true;
dec.IsNullSpecified = true;

CrmFloat f = new CrmFloat();
f.IsNull = true;
f.IsNullSpecified = true;

CrmMoney money = new CrmMoney();
money.IsNull = true;
money.IsNullSpecified = true;

CrmNumber number = new CrmNumber();
number.IsNull = true;
number.IsNullSpecified = true;

Lookup lookup = new Lookup();
lookup.IsNull = true;
lookup.IsNullSpecified = true;

PickList list = new PickList();
list.IsNull = true;
list.IsNullSpecified = true;

Status status = new Status();
status.IsNull = true;
status.IsNullSpecified = true;

Owner owner = new Owner();
owner.IsNull = true;
owner.IsNullSpecified = true;


Example
The following code example shows you how to create null instances of the various Microsoft Dynamics CRM attribute types using the type helper classes.

CrmBoolean boolean = CrmBoolean.Null;

CrmDecimal dec = CrmDecimal.Null;

CrmFloat flt = CrmFloat.Null;

CrmMoney money = CrmMoney.Null;

CrmNumber number = CrmNumber.Null;

Lookup lookup = Lookup.Null;

Picklist list = Picklist.Null;

Status status = Status.Null;

Owner owner = Owner.Null;


My Example
Moving the data from one field to another and cleaning the first field after that.

opportunity opp = new opportunity();
opp.opportunityid = new Key();
opp.opportunityid.Value = findedopp.opportunityid.Value;

opp.new_profittreshold = new CrmMoney();
opp.new_profittreshold.Value = (decimal)findedopp.new_investmenttreshold.Value;

opp.new_investmenttreshold = new CrmFloat();
opp.new_investmenttreshold.IsNull = true;
opp.new_investmenttreshold.IsNullSpecified = true;

service.Update(opp);

2008-07-21

Microsoft Dynamics CRM 4.0 SDK

Если кто-то еще не знает где взять(скачать) Microsoft Dynamics CRM SDK, то это можно сделать вот тут:

Microsoft Dynamics CRM 4.0 Software Development Kit

P.S. Версия SDK 4.0.5