Updating a CRM record when the record is in a read-only state such as Closed or Completed

 

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

o    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.  Below is a snapshot of the workflow for reference:

 

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. 

Please see the modified workflow screen shots for reference below:

 

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, I use them frequently!

4 comments

  1. I have tried before to automatically send emails after an entitiy is closed, only to find that the workflow would not execute because it could not add the related email to the history of the email. An example of this is closing a case and needing to notify the customer and/or billing about this event.Another potential issue is that there may exist a workflow that is triggered on the "re-opened" events. Following the example, if a workflow is run to send an email when a Case is closed, the Case will be reopened, and this might trigger a workflow that performas a set of steps when Cases are opened.I am very interested in knowing your opinion/experience about all of this.

  2. Hi Nestor,My apologies for not responding sooner but I didn’t receive the notification. If you have workflows that run on Case Status Change or some other event that is directly related to changing the Case status, then you will want to take that into consideration before creating this type of workflow.

  3. Hi Shai,I suggest you try this on the Order entity to see if it works. Some people have Order intgration with other application like Great Plains so you will want to take any integration or other business constraints into consideration before publishing this type of workflow into production.

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s