web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Closing Opportunity as lost with Status reason => 'Out-Sold' throws State code or Status Code Invalid error

(0) ShareShare
ReportReport
Posted on by 115

On Closing of an opportunity as Lost with Status reason => 'Out Sold'

pastedimage1597735590902v1.png

The below Shown Error Pops up 

pastedimage1597735631053v2.png

Can anyone please help me out to sort this issue..

Downloaded Error Log File details are Pasted below

{"ActivityId":"","errorCode":2147779592,"message":"1 is not a valid status code for state code OpportunityState.Lost on opportunity
with Id 7ed8668e-8ff6-4c3b-a2db-4c9d800f4615.","stacktrace":"
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, InvocationContext invocationContext,
CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, ExecutionContext executionContext,
Dictionary`2 optionalParameters)\r\n
at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.Execute(OrganizationRequest request, ExecutionContext executionContext)
\r\n at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.ExecuteOperation
(CrmODataExecutionContext context, EdmOperation edmOperation, Dictionary`2 parameters, Dictionary`2 boundParameters)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.ProcessOperationRequest(String operationName, Dictionary`2 operationParameters, EntityReference entityReference, String boundEntityName, String boundEntityType)\r\n at Microsoft.Crm.Extensibility.OData.ActionController.<>c__DisplayClass9_0.<PostUnboundAction>b__0()\r\n at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.<>c__DisplayClass10_0`2.<InvokeActionAndLogMetric>b__0()\r\n at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()","Timestamp":1597665992781}
Activity Id: cce5b574-cd5b-447f-ade3-9a84e6d3de35

I have the same question (0)
  • LuHao Profile Picture
    40,892 on at

    Hi partner,

    Could you provide a screenshot of the Status Reason field of Opportunity?

    pastedimage1597738022890v1.png

    Select Out-Sold option and click Edit, we could see its value. If it is the OOTB option, its value is 5.

    pastedimage1597738119528v2.png

    Is its value 1 in your environment?

  • MadhanSA Profile Picture
    115 on at

    Thanks for the response :) Yes, the value for Out-sold is 5 in my environment

    pastedimage1597747814999v1.png

  • Suggested answer
    Wahaj Rashid Profile Picture
    11,323 on at

    Hi,

    Do you have a workflow or plugin that sets the Opportunity Status or Status reason?

    Here is my theory in this scenario:

    • You try to close the opportunity with Out-Sold Status Reason (which comes under Status Lost)
    • I guess there is a workflow/plugin updating the Status Reason or Status field which is not of the same group. That means your opportunity has Lost Status but some other code is trying to set the Status Reason which comes under Open Status (or vice versa).

    I would suggest to disable workflows/plugins (updating status) for time being and see if this works.

    If this works fine with workflows/plugins disabled, i guess you can narrow down to the problematic part.

    Also, please look ate the following blog post, explaining this exception:

    https://community.dynamics.com/crm/b/passiondynamics/posts/is-not-a-valid-status-code-for-state-code-entity

    Let me know the results.

    Best,

    Wahaj

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 75 Super User 2026 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#3
11manish Profile Picture

11manish 52

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans