Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : BsJclFdHPuod/3PFs/K7f4
Microsoft Dynamics CRM (Archived)

State code or status code is invalid while deactivate the custom entity record

Like (0) ShareShare
ReportReport
Posted on 14 Jul 2014 13:15:32 by

Hi,

We have migrated to CRM 2013 and facing one issue while deactivating the custom entity record

Error-  State code or status code is invalid: State code is invalid or state code is valid but status code is invalid for specified state code

when downloading the log, it is giving below error.

<s:Envelope xmlns:s="<faultcode>s:Client</faultcode><faultstring">http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xmlns:xml="http://www.w3.org/XML/1998/namespace" xml:lang="en-US">-1 is not a valid state code on new_partner.</faultstring><detail><OrganizationServiceFault xmlns="<ErrorCode>-2147187704</ErrorCode><ErrorDetails">http://schemas.microsoft.com/xrm/2011/Contracts"><ErrorCode>-2147187704</ErrorCode><ErrorDetails /><Message>-1 is not a valid state code on new_partner.</Message><Timestamp>2014-03-18T05:42:04.5523897Z</Timestamp><InnerFault><ErrorCode>-2147187704</ErrorCode><ErrorDetails /><Message>-1 is not a valid state code on new_partner.</Message><Timestamp>2014-03-18T05:42:04.5523897Z</Timestamp><InnerFault><ErrorCode>-2147220970</ErrorCode><ErrorDetails /><Message>System.ArgumentException: -1 is not a valid state code on new_partner.
Parameter name: stateCode</Message><Timestamp>2014-03-18T05:42:04.5523897Z</Timestamp><InnerFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" i:nil="true" /><TraceText xmlns:i="http://www.w3.org/2001/XMLSchema-instance" i:nil="true" /></InnerFault><TraceText xmlns:i="http://www.w3.org/2001/XMLSchema-instance" i:nil="true" /></InnerFault><TraceText xmlns:i="http://www.w3.org/2001/XMLSchema-instance" i:nil="true" /></OrganizationServiceFault></detail></s:Fault></s:Body></s:Envelope>

*This post is locked for comments

  • Suggested answer
    v22arvind Profile Picture
    v22arvind 65 on 06 Jul 2020 at 16:42:25
    RE: State code or status code is invalid while deactivate the custom entity record

    For me it was a mistake in code where I was setting the integer value (0 or 1) to statecode attribute rather then setting it up as optionset.

    This one fails with above error message

    rec["statecode"] = 0;

    This one works fine:

    rec["statecode"] = new OptionSetValue(0);

  • David Pring Profile Picture
    David Pring 125 on 06 Jan 2020 at 22:25:59
    RE: State code or status code is invalid while deactivate the custom entity record

    Prior to UCI, I was updating only the status code but I've found that with UCI you need to update both the statecode and statuscode to get it working.

    Essentially I did this:

           Xrm.Page.getAttribute("statecode").setValue(1);

    Xrm.Page.getAttribute("statuscode").setValue(287850002);

    Xrm.Page.data.entity.save();

    Whereas prior to UCI it was only this:

           Xrm.Page.getAttribute("statuscode").setValue(287850002);

    Xrm.Page.data.entity.save();

    And technically, you should probably update it to this since Xrm.Page is being deprecated:

           formContext.getAttribute("statecode").setValue(1);

    formContext.getAttribute("statuscode").setValue(287850002);

    formContext.data.entity.save();

    Hope that helps

  • LindseyMET Profile Picture
    LindseyMET 13 on 22 Oct 2019 at 17:21:00
    RE: State code or status code is invalid while deactivate the custom entity record

    I am also experiencing this issue in the UCI when closing/deactivating a record. Any findings?

  • Community Member Profile Picture
    Community Member on 10 Oct 2019 at 11:03:35
    RE: State code or status code is invalid while deactivate the custom entity record

    we are facing the same issue in the UCI(unified Client interface).Any suggestions on the issue.

  • Suggested answer
    pfrederick1 Profile Picture
    pfrederick1 5 on 15 Jan 2018 at 20:23:19
    RE: State code or status code is invalid while deactivate the custom entity record

    We just experienced this issue working for a client. The client was unable to qualify Leads. We found that the statuscode was being mapped from the Lead to Account, which was causing the issue. Maybe that's the problem? Mapping statuscode from one entity to another doesn't make a whole lot of sense, so once we deleted the mapping and published we had no issues. Hope that helps!

  • Community Member Profile Picture
    Community Member on 19 Sep 2016 at 06:55:58
    RE: State code or status code is invalid while deactivate the custom entity record

    We are having similar issue. Did you find any solution for this?

  • Community Member Profile Picture
    Community Member on 09 Aug 2016 at 03:32:56
    RE: State code or status code is invalid while deactivate the custom entity record

    Hi,

    I have a similar issue. After I migrated to CRM 2016 from 2015, when trying to deactivate a custom entity record, I get the below error.

    State code or status code is invalid.

    State code is invalid or state code is valid but status code is invalid for a specified state code.

    <s:Envelope xmlns:s="schemas.xmlsoap.org/.../envelope"><s:Body><s:Fault><faultcode>s:Client</faultcode><faultstring xml:lang="en-US">1 is not a valid status code for state code progres_rsdreviewState.Inactive on progres_rsdreview with Id 22a3112d-91b6-e411-b429-005056817afb.</faultstring><detail><OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance"><ErrorCode>-2147187704</ErrorCode><ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"/><Message>1 is not a valid status code for state code progres_rsdreviewState.Inactive on progres_rsdreview with Id 22a3112d-91b6-e411-b429-005056817afb.</Message><Timestamp>2016-08-09T03:14:00.3755503Z</Timestamp><InnerFault><ErrorCode>-2147187704</ErrorCode><ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"/><Message>1 is not a valid status code for state code progres_rsdreviewState.Inactive on progres_rsdreview with Id 22a3112d-91b6-e411-b429-005056817afb.</Message><Timestamp>2016-08-09T03:14:00.3755503Z</Timestamp><InnerFault><ErrorCode>-2147187704</ErrorCode><ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"/><Message>1 is not a valid status code for state code progres_rsdreviewState.Inactive on progres_rsdreview with Id 22a3112d-91b6-e411-b429-005056817afb.</Message><Timestamp>2016-08-09T03:14:00.3755503Z</Timestamp><InnerFault><ErrorCode>-2147220970</ErrorCode><ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic"/><Message>System.ArgumentException: 1 is not a valid status code for state code progres_rsdreviewState.Inactive on progres_rsdreview with Id 22a3112d-91b6-e411-b429-005056817afb.
    Parameter name: statusCode</Message><Timestamp>2016-08-09T03:14:00.3755503Z</Timestamp><InnerFault i:nil="true"/><TraceText i:nil="true"/></InnerFault><TraceText i:nil="true"/></InnerFault><TraceText i:nil="true"/></InnerFault><TraceText i:nil="true"/></OrganizationServiceFault></detail></s:Fault></s:Body></s:Envelope>

    I tried checking the state and status code are in sync in CRM 2015 and 2016. But it works fine in the previous version but not in the later.

    I am unable to figure out the problem.

    Any help would be greatly appreciated.

    Regards,

    Ganesh A

  • Fighter Profile Picture
    Fighter 5 on 09 Feb 2016 at 08:43:08
    RE: State code or status code is invalid while deactivate the custom entity record

    Hi,

    Please, check that state field has the correct values in customizations.xml inside solution for this entity: invariantname="Active" and invariantname="Inactive". Translation of these values is not allowed.

  • Community Member Profile Picture
    Community Member on 24 Nov 2015 at 05:03:59
    RE: State code or status code is invalid while deactivate the custom entity record

    Hi ats,

    Did you ever find the cause of this issue?  We're experiencing it at a client site.  The fact it only occurs on the form and not the homegrid steers me away from data (as it would happen in both cases).

    Let me know if have any info.

    Thanks!

  • Community Member Profile Picture
    Community Member on 15 Jul 2014 at 08:59:04
    RE: State code or status code is invalid while deactivate the custom entity record

    Hi all,

    I have been able to activate deactivated records from homegrid. This error is only throwing when I activate deactivated form from record form.

    I think status code = 2 and state code = 1, in case of deactivated records.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading started