CRM 2013 - workflow that has to send a notification after 3 months from product end date RRS feed

  • Question

  • Hello,

    I have to set a workflow that sends a notification to a department after 3 months of the product end date.

    The problem was not to build the workflow but the concern that way too many process will stay in waiting all the contract period plus 3 months after and this will certainly will affect the servers.

    How i tested the wf:

    -wf set to work in the background

    - wf will start when the field is filled and when the "end date" is modified

    - Conditions:

     If the "end date" is equal to "start date" sau " end date" doesn't contains data

                  stop the wf with status: cancelled/finished

    If not:

             Timeout 3 months after "End date" then

                        Send email to the Department.

    My concerns:

    - for each product a wf will start and it will stay in pending for 1/3/6/12/24 months(depending of the product type) + 3 months after end date

    - all those processes in waiting will affect the server stability

    Any suggestions of how to modify this wf to start just once when i reach the end date not when i fill/modify the end date of the product?

    Thank you in advance for your response,


    Monday, April 20, 2015 8:22 AM

All replies

  • How many workflow process will stay in waiting? How many is to many? A wait workflow is just a persistent variable that pauses execution until a given time or condition happens - it does not consume any resources while waiting.

    This is more a question of how many waiting workflows can be expected to execute in the same time and what requirements you have to the execution speed of those. If you have several thousand workflow processes in waiting, and they all are expected to execute within a 10-minute interval 3 months ahead, things will likely fail. But if they are evenly distributed, I cannot see that it should have any implications

    Monday, April 20, 2015 8:35 AM
  • Thank you for reply!

    For each product that has a end date filled a wf will start. There are 5000+ active products with end date filled.

    For sure at the beginning there will not be such a high number of waiting workflows but in time it will gather thousands. 

    Monday, April 20, 2015 8:51 AM
  • I would not worry to much about that. They're just records (asyncoperation entity), there's no difference between those and any other records stored in the database. The difference is that they have a variable that the CrmAsyncService checks periodically.

    As long as you dont have any service level requirement where you need to ensure that thousands of procesesses are brought to completion within a very narrow timeframe, you're probably well within system limits

    Monday, April 20, 2015 8:55 AM
  • Some of colleagues said that they had to do similar wf  in the past and they had problems with the server. Maybe because our aplication is on-premise?

    The purpose of my question and my example was to find if there is another way to avoid all those waiting process.

    Is it possible to set a wf that for each date change to check if there are products with end date = to actual date?

    e.g. today 20.04.2015 00:00 the wf start to check if actual date(20.04.2015) = End date (of the product) then start counting 3 months...

                                                                                    if not kill wf...

    Sorry if my questions are not very well composed but I'm a rookie in CRM and i try as much as i can to learn. Now, I'm a little bit stuck with this wf.

    • Edited by aurashhh Monday, April 20, 2015 9:21 AM
    Monday, April 20, 2015 9:20 AM

  • Is it possible to set a wf that for each date change to check if there are products with end date = to actual date?

    e.g. today 20.04.2015 00:00 the wf start to check if actual date(20.04.2015) = End date (of the product) then start counting 3 months...

                                                                                    if not kill wf...

    That's more or less what the waiting activity in the workflow does. It calculates the waiting expression and sets the time and date when to execute the rest of the workflow.

    Alternatively you could write a scheduler service (i.e a windows service outside the CRM context) that polls the product record each night and and sends emails for the products. But that's about the same the workflow service does out of the box.

    Prevoiusly (CRM 4.0) workflow scheduling was a bit dodgy. But nowadays you're probably better off using workflows than writing your own code.

    Monday, April 20, 2015 9:38 AM
  • One option is outlined here

    (+ watch the video)

    Basically, you create a general-purpose "workflow assistant" entity, with a lookup to the entity(ies) you need to have bulk scheduled workflows for.

    When a product record is created, use a workflow to create a record of this child entity, linked to the product record.

    Create another workflow triggered when those "assistant" records are deleted, this one sends the email (if you already built that in a workfow, then clone it, make it a child workflow and tidy it up so it just does the email step and call that from this new one).

    Now the magic bit: you run a scheduled Bulk Delete that deletes "workflow assistant" records that have a parent product record that has an end date older than 3 months ago. This will delete all the assistant records for those products, triggering the workflow that sends the email.

    Schedule the Bulk Delete to run every 7 days (the minimum). If you need it to run every day, or every week day, just create multiple Bulk Delete jobs to run every 7 days, in effect a Monday job, a Tuesday job, etc.

    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    UK CRM Guru Blog

    Monday, April 20, 2015 12:53 PM