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 Service forum

I'm trying to Change the Owner of an Account it says The Contract is in invalid state

(0) ShareShare
ReportReport
Posted on by 60

When I'm trying to change the owner of an Account, an error comes and shows the contract is in an invalid state.

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The contract is in an invalid state.Detail:
<OrganizationServiceFault xmlns:i="www.w3.org/.../XMLSchema-instance" xmlns="schemas.microsoft.com/.../Contracts">
<ActivityId>fd3981fd-ea9d-4807-8b9c-a6dc4b11d641</ActivityId>
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="schemas.datacontract.org/.../System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>ApiExceptionSourceKey</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:string">Plugin/Microsoft.Dynamics.Service.Plugins.PreOperationContractUpdate</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiOriginalExceptionKey</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:string">Microsoft.Xrm.Sdk.InvalidPluginExecutionException: The contract is in an invalid state. ---&gt; Microsoft.Xrm.Sdk.InvalidPluginExecutionException: The contract is in an invalid state.
at Microsoft.Crm.Service.ObjectModel.ContractService.ValidateUpdate(Contract entity, Contract preImage, IPluginContext context)
at Microsoft.Dynamics.Service.Plugins.PreOperationContractUpdate.ExecuteCrmPlugin(LocalPluginContext localContext)
at Microsoft.Dynamics.Solution.Common.PluginBase.Execute(IServiceProvider serviceProvider)
at Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
--- End of inner exception stack trace ---
at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.PipelineInstrumentationHelper.Execute(Boolean instrumentationEnabled, String stopwatchName, ExecuteWithInstrumentation action, PipelineExecutionContext context)
at Microsoft.Crm.Extensibility.Pipeline.&lt;&gt;c__DisplayClass2_1.&lt;Execute&gt;b__0()</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiStepKey</d2p1:key>
<d2p1:value xmlns:d4p1="www.w3.org/.../XMLSchema" i:type="d4p1:string">77ea1e82-36b2-e611-80f3-00155d342d08</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>ApiDepthKey</d2p1:key>

.....................

.....................

Categories:
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    It looks like you have some custom plugin or workflow which is running on assign/ update of account and causing this issue. Check this and if possible try deactivate it and reporuc the issue. Once figured the plugin/ workflow, you can find out the cause.

    Hope this helps.

  • Bilal079 Profile Picture
    60 on at

    Hi Ravi,

    Thanks for your response,

    i think it is not due to any plugin, because this issue only with one account, other accounts are fine.

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    I think its plugin cause you are getting "Microsoft.Xrm.Sdk.InvalidPluginExecutionException: " exception which generaly occurs from custom plugin, real time workflow or business rule which runs on entity level.

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    can you check the relationship behaviour between account and contract? would be good if you upload the picture here. Futhermore, is this account associate to any contracts? if yes, check the status of that contract.

  • Verified answer
    Bilal079 Profile Picture
    60 on at

    Hi Wei Jie,

    Thanks for your response,

    i have fixed it already, you are right, it was hapened due to Contract State, Linked Contract was expired.

    and if we change the owner of an account, the owner of linked contract will also be changed due to parental relation.

    so i have removed the link of the contract and update the owner of the account.

    Thanks for your help.

  • Community Member Profile Picture
    on at

    Muhammad Bilal , I am kind of new at this and having the same issue as you had.  When you say "removed the link of the contract and update the owner of the account", did you go toe "Contract" entity, then N:1 Relationship?  Once there can you give me the steps to remove the link?  Also how to add it back in after I change the owner of the accounts.

    Thanks,

    Moe

  • Bilal079 Profile Picture
    60 on at

    Hi,

    Open your expired contract.

    make a copy of your expired contract and update the Contract End Date. (make sure you have all the contract lines and other things like currency, total price etc)

    add the customer of your expired cotract in your newly created contract.

    now you can delete the expired contract and update the owner of the account.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans