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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

state code or status code invalid when closing an opportunity

(0) ShareShare
ReportReport
Posted on by

We recently upgraded to Hosted CRM2013, a user is attempting to close an opportunity and gets the error code "state code or status code invalid" It wont let me download the log file to see where the error is occuring.

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    Hi Chasab,

    I take the follow post from here: social.microsoft.com/.../reopen-closed-opportunity-exception-invalid-state-for-this-entity-opportunity-1

    I had the same issue!

    The reason was that I had the

    a) statecode and statuscode fields on the form.

    b) there was JavaScript code that set for all fields submit=true (even for hidden & read-only fields)

    // Submit also dirty read/only attribute

    for (var i = 0; i < Xrm.Page.ui.controls.getLength(); i++) {

     var control = Xrm.Page.ui.controls.get(i);

     if (control.getDisabled()) {

    var controlName = control.getName();

    Xrm.Page.data.entity.attributes.get(controlName).setSubmitMode('always');

     }

    }

    When saving the form, the XML send to the platform contained

       <statuscode>1</statuscode>

       <statecode>0</statecode>

    (You can get it with Fiddler2)

    Once I had removed the statuscode field from the Form - the statecode is still there as readonly - it worked.

    Hope that helps!

    Could be your case?

    Let me know.

  • Chasab Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    There is currently no javascripts setup with our opportunities fields, Also since its hosted CRM i can't access Dev logs.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    But the status code in the CRM 2011 version was modified?

    If so, maybe something in the update to the 2013 version has been corrupted.

    Let me know.

    Bye

  • Community Member Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    Hello,

    Are we getting this error for all user or just one ?

    Is the user closing the opportunity as Won or Lost?

    Check on what status reason are we getting this error while closing the opportunity i.e. "Won" or "Lost"

    The above queries should help us to isolate this issue.

    Thanks

  • gslesz Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    I am getting the same exact error as CHASAB, also after the update to hosted CRM 2013 occurred. All my users are affected. Closing a lost opportunity works but closing as won does not. I also get state code or status code invalid. Download log file button is grayed out. This is happening on XP SP3, Outlook 2010 w CRM 2011 Client. I also get  "Microsoft CRM has encountered a problem and needs to close." error when switching between accounts or opportunities, every single time. We never had any issues until the update occurred. Below is the log file for the "Microsoft CRM has encountered a problem and needs to close." error.

    Exception generated at: 11/14/2013 10:10:48 AM

    Error Type: System.FormatException

    Error Message: Input string was not in a correct format.

    Error Stack Trace:

                   at Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)  ilOffset = 0x5A

                   at Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)  ilOffset = 0x15

                   at RollupByObjectCommand.RetrieveData()  ilOffset = 0x0

                   at ApplicationQuery.ExecuteQuery()  ilOffset = 0x0

                   at ApplicationQuery.GetViewData()  ilOffset = 0x54

                   at GridDataProviderQueryBuilder.GetData(QueryBuilder queryBuilder)  ilOffset = 0x14

                   at GridDataProviderQueryBuilder.LoadQueryData()  ilOffset = 0x12F

                   at GridDataProviderQueryBuilder.LoadData()  ilOffset = 0x0

                   at SubGridControl.LoadAsyncData(AsyncLoadDataParameters parameters)  ilOffset = 0x371

    Stack Frame:

                   at OutlookUtility.HandleExceptionInternal(Exception exception, Boolean showMessageBox, IWin32Window messageBoxOwner, String errorMessage)  ilOffset = 0x107

                   at CrmAsyncControl.verifyResults(IAsyncResults asyncResults)  ilOffset = 0xA8

                   at <>c__DisplayClass4.<beginLoadAsyncData>b__1()  ilOffset = 0x11

                   at <>c__DisplayClass7.<BeginInvokeSafe>b__5()  ilOffset = 0xB

                   at ExceptionFilter.TryFilterAllCatch(Action body, Action`1 filter)  ilOffset = 0xF

                   at <>c__DisplayClass7.<BeginInvokeSafe>b__4()  ilOffset = 0x1D

                   at RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)  ilOffset = 0xFFFFFFFF

                   at RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)  ilOffset = 0x16

                   at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)  ilOffset = 0x106

                   at Delegate.DynamicInvokeImpl(Object[] args)  ilOffset = 0x24

                   at Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)  ilOffset = 0xCF

                   at Control.InvokeMarshaledCallbackHelper(Object obj)  ilOffset = 0x20

                   at ExecutionContext.runTryCode(Object userData)  ilOffset = 0x29

                   at RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)  ilOffset = 0xFFFFFFFF

                   at ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)  ilOffset = 0x42

                   at ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)  ilOffset = 0x8E

                   at ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)  ilOffset = 0x9

                   at Control.InvokeMarshaledCallback(ThreadMethodEntry tme)  ilOffset = 0x4F

                   at Control.InvokeMarshaledCallbacks()  ilOffset = 0x63

                   at Control.WndProc(Message& m)  ilOffset = 0x64A

                   at ScrollableControl.WndProc(Message& m)  ilOffset = 0x41

                   at ControlNativeWindow.OnMessage(Message& m)  ilOffset = 0xC

                   at ControlNativeWindow.WndProc(Message& m)  ilOffset = 0x9A

                   at NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)  ilOffset = 0x25

  • Chasab Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    All users,

    Just Opportunities closed as won, Closing the same opportunities as lost functions normally.

    All status for Won result in the error, including new statuses created for testing.

    I currently have a ticket open with microsoft.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    As a test you could try to close the opportunity state with a WF...  

  • Chasab Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    This appears to work.

    I created a on demand workflow that checks the creator is me, and if so closes the opportunity as won status "test" and it is now closed as won.

  • Community Member Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    Ok, thanks... and if try to close as won from the list of record (selecting the opportunity) and not inside the single form... what happen?

  • Verified answer
    Community Member Profile Picture
    on at
    RE: state code or status code invalid when closing an opportunity

    Hello,

    This is a recently discovered issue with CRM 2013 in which custom status codes cannot be used for closing opportunities as 'Won' because the default value for Status reason field (Statecode ) "Won" is missing. Custom values are ignored and the system instead tries to save it with the system default status reason value of 'Won' and currently investigation is in progress.

    We may need to add the default value "Won" in the Customization.xml of opportunity entity as a workaround which should also take care of your issue and also now you do have another workaround which Marco suggested is also the better one temporarily i.e. closing the opportunity as won via workflow.

    Thank You.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans