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..





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
Hi Nick,
your connection string should be somthing like as follows..
Server=CRM-SRV-01;Database=Contoso_MSCRM;Trusted_Connection=True;
Server=<>;Database=<>;Trusted_Connection=True;
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..
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.
Detail:
0x80044191Assembly can not be loaded from C:\Program Files\Microsoft Dynamics CRM\server\bin\assembly\CRM4ContractUtilities.dll.
Platform
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
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.
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?
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..
Thanks a million.
Worked a Treat…
Hello
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.
Rgds,
Coolpilot
This is great, thanks. Do you by any chance have a similar custom step to change the draft contract back to active?
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..
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?
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 )
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 …
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.
for CRM 2011 please see following post.
http://mayankp.wordpress.com/2012/03/05/crm-2011-changing-crm-activeinvoice-contract-to-draft/
thank you very much, your blog is great