locked
Running a Workflow Daily in Dynamics CRM 2011 Online RRS feed

  • Question

  • I have a Workflow I want to execute DAILY in Dynamics CRM 2011 Online. My initial research concluded that there is no out-of-the-box solution for scheduling Workflows; however, I did come across a very helpful blog post with a creative work-around (http://gonzaloruizcrm.blogspot.com/2011/05/quite-often-we-have-business-process.html).

    Following the instructions in the blog post, I created a Workflow marked as On-Demand and Child Process that has all of the conditions I need. Then I added a step at the end with a Wait condition followed by starting a Child Workflow (so the process will call itself).

    My Workflow looks like this:
    1. Check condition - are there items in X Queue that are e-mails?
    2. If so, send an e-mail to X users (I created the e-mail; I did not use a template)
    3. Wait condition - process timeout equals 1 day
    4. Then start Child Workflow - the current Workflow

    I started the Workflow and everything functioned as expected; however, the Workflow only re-started itself once. After running a second day, step 4 is marked as completed, but the Workflow is not started again.

    I am using this work-around in order to avoid the loop issue CRM has regarding recurring Workflows. Is there a reason why my Workflow will only run twice? NOTE - the entity I am using is Queue Item.

    Additional note - I tried to comment on the original blog post regarding this topic; however, I am unable to access the text field to enter the CAPTCHA for my comment, so I cannot submit.

    Wednesday, June 15, 2011 3:51 PM

Answers

  • I Meghan, ok, I'm glad we are getting closer to the real problem!

     

    The condition you have above means:

    "If the queue to which the current item belong is equal to queue X and if this current item is of type email". Note that it is very different from "are there items in X Queue that are e-mails". I think you have a problem with your condition, it does not represent what you logically mean.

     

    To find out whether there are items in X Queue which are emails you unfortunately would have to write a custom workflowe activity, it would not be possible to configure that condition with the workflow designer in the application.


    Gonzalo | gonzaloruizcrm.blogspot.com

    • Marked as answer by Meghan Deaver Wednesday, June 15, 2011 8:39 PM
    Wednesday, June 15, 2011 8:35 PM
    Moderator

All replies

  • Hi Meghan,

    Each time the workflow enters into a new loop (after step 4), the step4 is markes as completed, and a *new* workflow is started which will then start from step1, it is not the same workflow. So each day you will have a new system job for the new child workflow. If the step4 is marked as completed then it means a child workflow was started and you have to find it.

     

    Also, if you open the system job which as step4 completed you should be able to click in the link for step4 and it will take you to the new child workflow. That way you can track down all the different instances that have executed.


    Gonzalo | gonzaloruizcrm.blogspot.com

    Wednesday, June 15, 2011 4:28 PM
    Moderator
  • Thank you, Gonzalo (and thank you for the blog post)!

    I did as you suggested (clicking the link for step 4) and it does take me to the next child workflow. The "Regarding" field is the same in each subsequent child workflow, and all of the steps are marked with a green check (indicating the step succeeded); however, I do not believe the later child workflows are functioning correctly.

    For example, on day 3, there is a child workflow with a status of Succeeded. It has the same "Regarding" field as the initial workflow I started on-demand. All of the steps indicate they were completed successfully; however, there are e-mails in the X Queue, so if the workflow was functioning correctly, there should have been an e-mail generated. No e-mails were recieved. I tested this again today and the workflow generated an e-mail message without issue and the "timeout" timestamp is correct.

    Could this be caused by the "Regarding" field being the same each day? Should I change the Entity to "Queue" instead of "Queue Item"?

    Wednesday, June 15, 2011 4:43 PM
  • Hi Meghan,

     

    What is the primary entity of your workflow? is it queue?

    You must pass the primary entity to the child workflow as well, so the child workflow will have the same regarding as the parent.


    Gonzalo | gonzaloruizcrm.blogspot.com

    Wednesday, June 15, 2011 5:13 PM
    Moderator
  • The primary entity is Queue Item. The workflow I created is a child workflow - the last step calls itself to start so that the workflow runs in a loop.
    Wednesday, June 15, 2011 6:28 PM
  • The recurrence pattern is supposed to work, when you check the system job, at the start child workflow step, just before the "view properties" link there should be a link to the system job to the child workflow.

     

    Now it seems to me you are confusing the problem that the email is not getting sent with the fact that the workflow starts a child instance every day, it is not possible that it magically "stops" calling itself unless it fails or is cancelled, so that's why I'm saying that you can navigate the entire workflow chaing by following the link in the system job.

    How are you checking whether an X queue contains items which are e-mails? (you mean the queue item?)


    Gonzalo | gonzaloruizcrm.blogspot.com

    Wednesday, June 15, 2011 7:51 PM
    Moderator
  • Hi Gonzalo,

    Thank you again for your reply! Yes; using the steps you provided, I am able to verify the workflow is starting a child instance every day, so this issue is resolved.

    However, the initial reason I thought the child instance wasn't being called properly is because the workflow was not generating a daily e-mail. We have now verified that the child instance is running daily, but the step to send an e-mail if  the check condition is met is not happening (though the child instance displays this as a completed step).

    My check condition is: If Queue equals [X] AND [Queue Item:Type equals [Email]]

    I verified there are e-mails in Queue X and they entered this Queue after I kicked off the initial workflow; so I assume the child instance should catch these new items using the Check Condition; is that correct?

    Wednesday, June 15, 2011 7:59 PM
  • I Meghan, ok, I'm glad we are getting closer to the real problem!

     

    The condition you have above means:

    "If the queue to which the current item belong is equal to queue X and if this current item is of type email". Note that it is very different from "are there items in X Queue that are e-mails". I think you have a problem with your condition, it does not represent what you logically mean.

     

    To find out whether there are items in X Queue which are emails you unfortunately would have to write a custom workflowe activity, it would not be possible to configure that condition with the workflow designer in the application.


    Gonzalo | gonzaloruizcrm.blogspot.com

    • Marked as answer by Meghan Deaver Wednesday, June 15, 2011 8:39 PM
    Wednesday, June 15, 2011 8:35 PM
    Moderator
  • Oh, ok. I did not realize the logic did not match up. Thank you for clarifying!

    Wednesday, June 15, 2011 8:39 PM