locked
Workflow: check if date is before opportunity's estimated close date (and some other WF-questions) RRS feed

  • Question

  • I'm building a workflow using the CRM engine, and it is based on the estimated close date of an opportunity. Here is how it is supposed to run:

    Workflow 1 (Started when opportunity is created):
    timeout until 7 days before estimated close date.
      if opp's status is open
         send e-mail to owner
         Start workflow number 2
      else
         stop workflow

    Workflow 2
      Timeout until workflow  execution time 1 day after execution time
      if opp's status is open
        if (date <= opp's estimated close date) ?????
            send e-mail
            start workflow 2
        else
            stop workflow
      else
        Stop workflow


    The part I haven't figured out yet (the ??????-line) is how to detect if the date is 6 days or less (already covered the 7th day) before the opp's estimated close date.

     Is it possible to detect this? Or do have have to introduce another workflow or something else..?

    Another question is, in workflow 1, what if the estimated close date changes after saving the opportunity the first time (the workflow is started when an opportunity is created). Let's say that on the first save (is on Oct 1st)  the close date is 1st November, but one week later the close date is changed to 14th of November. Will the workflow trigger on the 1st or the 14th the first time? And what would happen if the trigger of the workflow is set to oncreate of opportunity and onchange of the attribute estimated close date. Will it be fired twice on the 7th of November?


    And in workflow 2: what if the close date is changed the 27th of October to the 14th of November. Then workflow number 2 has been running for a few days. Will it stop or will it just continue? It was started with 1st of November as the close date, but will it take into consideration the change to the 14th??
    Monday, September 28, 2009 7:01 AM

Answers

  • With the 6 days thing, I don't understand why you need to decrement the days if you are already waiting 24 hours with the timeout and looping. To achieve this will require storing the current value and passing it to the next workflow. There may be a clever way to do this but it will probably require a custom workflow or, as you say, one big workflow with lots of emails to maintain.

    The problem I see with decrementing the dates is if the estimated close date moves out. Let's say the customer says, after the salesman has received 5 emails, that they're not ready to move now but possibly will be in a month. The sales guy will only get 2 days warning if we decrement the days whereas I'm thinking resetting back to 7 would be the way to go.

    Therefore I'm thinking you leave the days at 7. If it triggers, the salesperson gets daily reminders until the shift the estimated close date or finish the opportunity and if they do shift the estimated close date, the reminder mechanism effectively resets to seven days. 

    In fact, now that I think about it, you may be able to get away with just one workflow.

    Triggered on create and available as a child.

    Timeout 1 day
    if '7 days before estimated close date' and 'opportunity open' then send email
    if 'opportunity open' then call workflow

    Its pretty early in the morning here but I think that would do the job. NB: There are no 'else' clauses here. The statements run and are tested.

    If you want to have it with an else, you could cast it as

    Timeout 1 day
    if '7 days before estimated close date' and 'opportunity open' then send email, call workflow else
    if 'opportunity open' then call workflow

    Leon Tribe
    Want to hear me talk about all things CRM? Check out my blog
    or hear me tweet @leontribe


    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/ or hear me tweet @leontribe
    • Proposed as answer by Leon TribeMVP Tuesday, September 29, 2009 8:23 PM
    • Marked as answer by flowjob Wednesday, September 30, 2009 11:03 AM
    Tuesday, September 29, 2009 8:23 PM

All replies

  • For the number of days issue, I'd probably stick to 7 as the only time this is going to be significant is if the estimated close date moves out anyway. Let me know if I'm misinterpreting your intention.

    The good news is workflows are clever in regards to shifting dates. If the condition is '7 days before Estimated Close Date' the workflow will not trigger until this condition is met. It checks every time is 'wakes up'. So if you push the date out 5 days, the workflow will wait the extra 5 days automatically.

    If you trigger the workflow onchange, then, yes, multiple workflows will be created which, in this case, would be undesirable.

    The only complication is that CRM has a primitive infinite loop checker so you might find wf2 stops repeating after half a dozen or so repeats. If this is the case you may need to create a clone (wf3) and have wf2 and wf3 call each other instead.

    Leon Tribe
    Want to hear me talk about all things CRM? Check out my blog
    or hear me tweet @leontribe

    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/ or hear me tweet @leontribe
    • Proposed as answer by Leon TribeMVP Monday, September 28, 2009 7:50 PM
    Monday, September 28, 2009 7:50 PM
  • Hi Leon,

    Don't know if I understood what you might have been misinterpreting :) The 7 days are easy to detect, and as I understood if the close date is changed before this triggers, then the workflow will wait even longer. That's fine. However, for workflow 2, your saying that it would be hard to detect if the date is less then or equal to 6 days before, or equal to the close date? Or is it impossible?? Could it be done with a custom workflow activity?

    My first take on this was to have one workflow waiting for 7 days, 6 days, 5 days and so on...but then I would have to create 7 e-mails, and there would be 7 e-mails to maintain in one workflow.

    Monday, September 28, 2009 8:59 PM
  • With the 6 days thing, I don't understand why you need to decrement the days if you are already waiting 24 hours with the timeout and looping. To achieve this will require storing the current value and passing it to the next workflow. There may be a clever way to do this but it will probably require a custom workflow or, as you say, one big workflow with lots of emails to maintain.

    The problem I see with decrementing the dates is if the estimated close date moves out. Let's say the customer says, after the salesman has received 5 emails, that they're not ready to move now but possibly will be in a month. The sales guy will only get 2 days warning if we decrement the days whereas I'm thinking resetting back to 7 would be the way to go.

    Therefore I'm thinking you leave the days at 7. If it triggers, the salesperson gets daily reminders until the shift the estimated close date or finish the opportunity and if they do shift the estimated close date, the reminder mechanism effectively resets to seven days. 

    In fact, now that I think about it, you may be able to get away with just one workflow.

    Triggered on create and available as a child.

    Timeout 1 day
    if '7 days before estimated close date' and 'opportunity open' then send email
    if 'opportunity open' then call workflow

    Its pretty early in the morning here but I think that would do the job. NB: There are no 'else' clauses here. The statements run and are tested.

    If you want to have it with an else, you could cast it as

    Timeout 1 day
    if '7 days before estimated close date' and 'opportunity open' then send email, call workflow else
    if 'opportunity open' then call workflow

    Leon Tribe
    Want to hear me talk about all things CRM? Check out my blog
    or hear me tweet @leontribe


    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/ or hear me tweet @leontribe
    • Proposed as answer by Leon TribeMVP Tuesday, September 29, 2009 8:23 PM
    • Marked as answer by flowjob Wednesday, September 30, 2009 11:03 AM
    Tuesday, September 29, 2009 8:23 PM
  • Thanks Leon,

    I think you cleared some confusion about how to build the workflow, and I do believe that your workflow will work.
    Wednesday, September 30, 2009 11:03 AM