locked
Loop in CRM Workflow RRS feed

  • Question

  • I want to create a custom loop activity in crm, e.g. a while loop.

    "while mystatus==anystatus
    execute another activity"

    Is there any way to implement this?

    Thanks!
    Jan
    Wednesday, January 13, 2010 5:10 PM

Answers

  • As far as scopes go, I would sooner establish the loop in your code, rather than in the Workflow that uses it.  The reasons for this are numerous, not the least of which being:

    a.) every time a Workflow executes, many System Job entries are processed and logged by the platform, increasing the size of your database, and possibly hampering performance;  though you can get around this with BulkDelete jobs to clean up, or enable automatic bulk deletes of system job data (the process for this is described in more recent Rollup Update packages for CRM)
    b.) Asychronous CRM execution makes use of multiple WebServices calls back to the CRM platform.  A constantly operating Workflow may tie up IIS resources.  Especially if there are many entities executing this Workflow simultaneously.  Even worse, if each Workflow is constantly attaching--individually--to an external resource, that resource may run out of resources as well, causing a cascading effect of failures.
    c.) attendant notification: if after an arbitrary number of sequential failures, say 5000, your solution will continue to spool away in the background, consuming resources on the server, when direct attention is required to resolve a problem with this external service.  If your code contained the loop internally, and returned a status string, or the raw number of failures after a set number of executions, the Workflow could examine this and send you an email to notify you that a problem requires your attention.

    I suspect you're trying to monitor the state of an attribute until it's been changed to some acceptable value, after which the workflow no longer runs.  However, if you're instead trying to setup code that runs all the time, regardless of the value of this monitored attribute, I do not believe a Workflow is the best place to run this code.  You may be better off, for resources, speed, and raw number of IIS interactions, to establish this code into a new windows service or application.
    Dave Berry
    Wednesday, January 13, 2010 6:56 PM
    Moderator

All replies

  • You can use recursive workflow but why don´t you use Record attribute change ?
    Gruß Carsten Groth http://carstengroth.spaces.live.com
    Wednesday, January 13, 2010 5:39 PM
  • My Custom Activity calls a service which might return a timeout. I just want to restart the custom activity after a few seconds for a couple of times.
    For that reason, i want to create a "service loop" around that activity....

    Regards
    Jan
    Wednesday, January 13, 2010 5:54 PM
  • As far as scopes go, I would sooner establish the loop in your code, rather than in the Workflow that uses it.  The reasons for this are numerous, not the least of which being:

    a.) every time a Workflow executes, many System Job entries are processed and logged by the platform, increasing the size of your database, and possibly hampering performance;  though you can get around this with BulkDelete jobs to clean up, or enable automatic bulk deletes of system job data (the process for this is described in more recent Rollup Update packages for CRM)
    b.) Asychronous CRM execution makes use of multiple WebServices calls back to the CRM platform.  A constantly operating Workflow may tie up IIS resources.  Especially if there are many entities executing this Workflow simultaneously.  Even worse, if each Workflow is constantly attaching--individually--to an external resource, that resource may run out of resources as well, causing a cascading effect of failures.
    c.) attendant notification: if after an arbitrary number of sequential failures, say 5000, your solution will continue to spool away in the background, consuming resources on the server, when direct attention is required to resolve a problem with this external service.  If your code contained the loop internally, and returned a status string, or the raw number of failures after a set number of executions, the Workflow could examine this and send you an email to notify you that a problem requires your attention.

    I suspect you're trying to monitor the state of an attribute until it's been changed to some acceptable value, after which the workflow no longer runs.  However, if you're instead trying to setup code that runs all the time, regardless of the value of this monitored attribute, I do not believe a Workflow is the best place to run this code.  You may be better off, for resources, speed, and raw number of IIS interactions, to establish this code into a new windows service or application.
    Dave Berry
    Wednesday, January 13, 2010 6:56 PM
    Moderator
  • Thanks for your reply.

    I created serval workflow activities that are responsible for a specific task, e.g. "create sharepoint document library for an account".

    This certain activity has three result states: ok, error, timeout.

    My intention regarding the loop question is to develop a manager-activity that takes care of all those activities.

    In other words, it should try to run the "workspace" activity again if it results in a timeout.


    I do not want to implement this inside each activity's code because it should be a stand-alone, user-configurable and reusable component.


    Thanks and regards
    Jan
    Wednesday, January 13, 2010 8:44 PM