Sitemap

Wednesday, November 22, 2017

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