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 is invalid while deactivate the custom entity record

(0) ShareShare
ReportReport
Posted on 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

I have the same question (0)
  • Suggested answer
    v22arvind Profile Picture
    65 on at
    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
    125 on at
    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
    13 on at
    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
    on at
    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
    5 on at
    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
    on at
    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
    on at
    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
    5 on at
    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
    on at
    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
    on at
    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

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)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans