Changing CRM Active/Invoice Contract to Draft

Sometime back I posted on how to change/delete read only records in Dynamics CRM but this does not work for contract.

Contract record once becomes active/invoice there is no supported way to change the contract back to draft. So I created custom workflow activity which allows users to change contract back to draft.
Once contract is in draft state, user can change any fields or delete the contract from the system.
I have shared this utility on CodePlex at Here

This application also contains some other contract utility. Following are the details steps regarding usage of this application

Step 1: Download the application files and register this assembly using plug in registration tool

Step 2 : Once assembly is registered successfully, go to setting and create new workflow against contract, make sure contract is owner by admin user who have access to modify the database tables.

Step 3: Call this workflow “Change Status to Draft” and add step from Contract utilities -> Change Status to Draft. (As per following screen print).

Step 4: provide input parameters (i.e. database connection to string)

Step 5: Now publish the workflow.

Step 6: go to contract screen and run this workflow against relevant active/invoiced contract record and this workflow will make contract draft. Now user can change any field on this contract or delete the contract now

Note: This is unsupported customization, Please unit test this module on your development/test environment before applying it to Live Environment..


20 thoughts on “Changing CRM Active/Invoice Contract to Draft

  1. Nick

    This util sounds great as currently I have to go in to SQL and edit the data manually however I cannot get it to work.

    1) Plugin registered
    2) Workflow set up.
    3) Run workflow but get an error (no details shown)

    I have a feeling this might be down to my DB connection string. Please can you advise of the correct format…. thank you !

    I get an error when I try and run the workflow

    1. mayankp Post author

      Hi Nick,

      your connection string should be somthing like as follows..



      Also make sure owner of the workflow is someone who can update table records in CRM, someone who is Admin on your system and then it should work fine…

      even after this it does not work then please paste the error description over here and I will able to provide resolution after that..

  2. Marco

    Hi, Thanks for this utility… I tried to register the .dll but I’m not able to, I keep getting this error, do you know why?

    Unhandled Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request.
    Assembly can not be loaded from C:\Program Files\Microsoft Dynamics CRM\server\bin\assembly\CRM4ContractUtilities.dll.

    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

    I’m able to register my plugins normally, but only this one fails. Thanks

    1. mayankp Post author

      have you put the assembly in to the C:\Program Files\Microsoft Dynamics CRM\server\bin\assembly folder and register it as disk?

      try registring this as database becuase this is recommanded option.

  3. Marco

    Thanks, it worked when registering as database. This workflow can only be run by an administrative user? I need certain Roles(that not necesarly have DB permissions) to be able to execute a Plugin that would call this workflow. Plugin would change status of the contract, update some values and put it back to Active.

    Is this possible with this approach?

  4. mayankp Post author

    Yes, becuase only admin person can have access to database directly….

    if workflow is published under Admin account and then if it shared with all user (i.e. give all user read rights) then this would work..

  5. Coolpilot

    Thanks for this utility. It works fine in an originally setup environment.
    But it does not work in our production environment where there are renamed entities. These names are in German, but it does work in the original version with language packs.
    Any suggestions what should be changed in the source code to make things work?
    I am not a programmer but have those at hand if needed.
    Thanks a lot for any input in advance.

    1. mayankp Post author

      you do not need any custom step to make Draft to Active becuase standard workflow will allow you do this anyway..
      so create new on demand workflow against contract and add step to change workflow status to Active/Invoice and then run them against draft contracts..

      1. STH

        I have tried that. My workflow starts with a check condition. If that’s met it sends and email, then uses your step to make the contract draft. After that it updates the record to set a flag. The final step is Change record status to: Contract Active. That final step fails with the message “The status of the contract does not allow this action”. Any ideas please?

  6. XHEO

    Hi I have also the same error as STH : changing back the contract status to Active fails. I have done it in
    -step in my workflow
    – and tried also a separate workflow
    But I had the same problem : workflow in waiting ( the status of the contract does not allow this action )

    1. mayankp Post author

      you need to put following line to your workflow editor..

      change status to Invoiced

      so even though you want to make it active set status to invoice and it will work fine …

  7. ms1973

    Hi, would it be also be possible to post the sourcecode for this functionality here, so it can be compiled for CRM 2011?
    This would help greatly! Thank you.

    Ah, any hints how I can make a custom workflow which allows me to attach/edit/delete CONTRACT LINES? That would be even a bigger thing 😉

    have a nice one…cu.

  8. Pingback: CRM 2011 Changing CRM Active/Invoice Contract to Draft « MayankP's Blog

  9. Pingback: CRM 2011 Changing CRM Active/Invoice Contract to Draft - MayankP’s Blog - CRM Technical Blogs - Microsoft Dynamics Community

  10. Mark Bath

    I am confused about the contractId property that you show as {Contract(Contract)} in your instructions. I can not entere text in this “lookup” field. What am I missing here? If I select a specific Contract the workflow works like a champ , except it doesn’t update the screen form and re-sets the selected contract regardless of the contract it is called from.

  11. mayankp Post author

    Hi Mark,
    this property {Contract(Contract)} allows you to pass the selected contract dynamically.

    the way you can set this property is as follows.
    once you open the input parameter screen, click inside contract look up, and then from right hand side (i.e. form assistant) select contract and click ok and this will make sure you will have contract supplied dynamically correctly..

    you do not have to pass the contract hard coded..

    hope this helps..


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s