You many need to cancel Order, Invoice or any other record using workflow.
Before cancelling the workflow, you must check whether the record is already in cancel status.
If the record is already in cancel status, when you are trying to cancel it again, you will experience below error.
Workflow paused due to error: Unhandled Exception:
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The entity cannot be closed because it is not in the correct state.Detail:
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType) at Microsoft.Crm.Extensibility.InprocessServiceProxy.ExecuteCore(OrganizationRequest request) at Microsoft.Crm.Workflow.Services.SetStateActivityService.<>c__DisplayClass1. -2147220941 The entity cannot be closed because it is not in the correct state. 2011-11-02T06:09:20.2231504Z
-2147220941 The entity cannot be closed because it is not in the correct state. 2011-11-02T06:09:20.2231504Z b__0(IOrganizationService sdkService) at Microsoft.Crm.Workflow.Services.ActivityServiceBase.ExecuteInTransactedContext(ActivityDelegate activityDelegate) at Microsoft.Crm.Workflow.Services.SetStateActivityService.SetStateInternal(String entityName, Guid entityId, Int32 state, Int32 status) at Microsoft.Crm.Workflow.Services.SetStateActivityService.ExecuteInternal(ActivityContext executionContext, SetState setState) at Microsoft.Crm.Workflow.Services.SetStateActivityService.Execute(ActivityContext executionContext, SetState setState) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Thanks, you saved me today.
ReplyDelete