Ever wonder how to update Closed or Completed CRM records like Activities, Quotes, or Opportunities that are in Completed, Won or Lost status using a supported method that does not require writing code or custom workflows? If so, here is a solution leveraging workflows in Dynamics CRM 4.0 which was not possible in the CRM 3.0 version.
I recently had a requirement to automatically update a field on an Opportunity and Quote record with a data value from the related Order when an Order was created. The date value is the Booking Date of the Order which is generally different from the date the Order is processed. Since I was aware that the related Quote and Opportunity would be in read-only status (Won) after the Order was created, per the business practice of the company, I knew the workflow logic had to include something like the below:
- Update the Quote Status to Draft / In Progress
- Update the Quote field per requirements
- Update the Quote Status to Active
- The Quote must be in Active Status in order to change it to Won status
- Update the Quote Status to Won
- Update the Opportunity status to Open / In Progress
- Update the Opportunity field per requirements
- Update the Opportunity to Won
- Stop the workflow as Succeed
I began by creating a fairly simple workflow on the Order entity which included the steps above.
As you can see, I set the Workflow Scope to Organization, selected to start the workflow when the Order field changed, and made the workflow available to run On Demand for testing and updating existing records. Using the Order field change as the trigger rather than when the Record is created, allowed me greater flexibility to ensure I was catching all changes and not just those generated when a new record was created.
After saving and publishing the workflow, I tested it on a few Order records. I gave the system jobs adequate time to complete and ran an Advanced Find query on the system jobs with the name of the workflow to ensure everything completed as expected. I included filtered criteria to show all systems jobs where the Status Reason; did not equal Canceled or Succeeded. The query returned a small set of records where the System Job was in Waiting Status.
I opened the System Job to see if I could identify the issue and discovered that the issue occurred because the user neglected to associate an Opportunity with the Order record. The job did not complete as expected since it could not find the related Opportunity record.
To address this scenario, I inserted a step in the workflow that first checks the Order record for the related Quote, sends an e-mail notification to CRM Admin if there is no related Quote, and cancels the workflow. I created a similar check for the Opportunity.
To complete the change request requirements, I also needed to update existing Opportunity and Quote records with the required data value. Normally, one could simply use the default Order view of Active Orders, but this particular Company had Orders in both Active and Submitted status. To ensure I captured a full list of the Order records, I created an Advanced Find view on the Order entity and used the filter criteria: Order Status does not equal Canceled. I ran the workflow on the Order records and the workflow updated both the Quote and Opportunity records with the field data value as expected.
One item worth mentioning is that if you have a large record set to update, you may want to wait until after hours to apply the workflow or apply the workflow to a subset of records in stages to minimize performance impact. I had a little over 4 hundred records to update so it did not impact performance.
Thanks to Microsoft for the enhancements made to workflows.
We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!