Monday, April 19, 2010

CRM: update statecode and statuscode

You can not update the state/status of an entity using service.update method.

Each entity, including new customized ones have a "setstate" request class.
for example, if you want to set the state of account:
----------------------------------------------------
CrmService service = new CrmService();
SetStateAccountRequest setacc = new SetStateAccountRequest();
setacc.EntityID = new Guid("");
setacc.AccountState = new AccountState();
setacc.AccountState = AccountState.Inactive;
service.Execute(setacc);
----------------------------------------------------