Update statecode and statuscode in MS CRM

In general we do use update method of organization service to update any record in crm, but it doesn't work to update statecode or statuscode. Below is the code snippet we should use to update these fields.

                SetStateRequest setStateRequest = new SetStateRequest();
                setStateRequest.EntityMoniker = new EntityReference("your entity name", recordGuid);

                setStateRequest.State = new OptionSetValue(stateCode);
                setStateRequest.Status = new OptionSetValue(statusReason);

                SetStateResponse setStateResponse = (SetStateResponse)service.Execute(setStateRequest);

No comments:

Post a Comment

Featured Post

Improving MS CRM Performance

Performance on MS CRM is always a crucial thing and we may follow different ways to achieve the performance thing. Below is the one more a...