web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Infinite Loop Error in Workflows

(0) ShareShare
ReportReport
Posted on by

Hello Experts,

We have used out-of-the-box workflows to implement recurring requirement as specified below but we are getting an error in the workflow as:

"This workflow job was canceled because the workflow that started it included an infinite loop. Correct the workflow logic and try again. For information about workflow logic, see Help."

Note: The workflow is working fine in case it executes after every hour or more but we need to execute it every 5 minutes.

The requirement to implement in Dynamics 365 V8.2 on-premises as follows:

Create a recurring workflow that executes every 5 minutes and triggers another instance of the same workflow on each execution.

Consider a scenario,

On create of a record of Entity A, the recurring workflow gets started and wait until next 5 minutes.

After 5 minutes, it performs the logic and calls a new instance of the same workflow again to wait for the next 5 minutes.

The execution of the current workflow stops after calling a new instance of the same workflow.

ie. for each of the record of Entity A, there will always exist a waiting workflow.

Please help.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Ben Thompson Profile Picture
    6,350 on at
    RE: Infinite Loop Error in Workflows

    Dynamics 365 will not allow you to create a workflow as you describe as it's almost a self-inflicted denial of service attack. You can in theory task a workflow to start again in an hours time but not before then and even then I wouldn't recommend it.

    What task is the workflow trying to perform? You really need to move it outside Dynamics 365 and use a scheduled task calling say a console application to identify the records that need to be updated / processed and then either update them via within the console application or trigger an action (inside Dynamics 365) to work on those records.

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at
    RE: Infinite Loop Error in Workflows

    Hi Jeetjg

    You are getting the infinite loop because the same workflow is triggered either by the event like update or calling the workflow again and again without a breaking condition.

    When you do a recurring workflow, you will have to have a flag on the entity to mark that already a running session of the workflow.

    With combination of the flag and timeout of 5 minutes, you can achieve what you want.

    Let me know if you need more guided examples as to how you can achieve this.

    Have a look at this link as well to help you change your workflow to work in the way you want

    www.powerobjects.com/.../multiple-waiting-workflows-wait-conditions-and-timeouts

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at
    RE: Infinite Loop Error in Workflows

    Hi There,

    this is very common i often see with the re-occuring workflow. This is because Dynamics 365 for Customer Engagement has a built in safeguard to prevent infinite loops, which can severely bog down the system.  If a workflow calls itself more than seven times within an hour, the eighth attempt will fail.  To fix your workflow, simply set the duration to something more reasonable.

    now in your condition because you need to do it in every 5 minutes - there doesnt seem to be a way. if you can introduce a timeout time of 1 hour or more then it will work.

    solution to the problem. use bulk delete feature to achieve this functionality : similar to this approach : [View:https://passion4dynamics.com/2017/12/24/escape-from-waiting-condition-workflows-microsoft-dynamics-crm-2016/]

    or create a simple console application which should call this workflow every 5 minutes.

  • Suggested answer
    Sreevalli Profile Picture
    3,256 on at
    RE: Infinite Loop Error in Workflows

    Hi,

    You can create a custom entity, that should be added as child on create of Entity A record and then you can go for loops on world on child record. since you are doing all the logic on parent there will not be any extra wait jobs and infinite loops. let me now if you need more details on this approach.

  • Community Member Profile Picture
    on at
    RE: Infinite Loop Error in Workflows

    Hello Ben,

    Thanks for your update.

    The workflow is trying to update a field of a parent entity with the aggregation of a field from all of its child entities.

    Also, it would not be possible for me to take it out of CRM as I have a different run time for each of the parent entity record.

    ie. Parent Record 1 will update every 5 minutes, Parent Record 1 will update every 10 minutes etc.

    Please suggest an alternate approach based on the details provided above.

    Thank you,

  • Community Member Profile Picture
    on at
    RE: Infinite Loop Error in Workflows

    Hello Kokulan,

    Thanks for your update.

    I have gone through the provided link but then my scenario is a little bit different.

    On each execution of the waiting workflow, I would like to update the next execution date (ie. any DateTime field on the entity) and again start a new instance of the same workflow to wait till the next execution date.

    In short, I would like to execute the same workflow logic again and again in the interval of say 5 minutes.

    Please suggest an alternate approach based on the details provided above.

    Thank you,

  • Ben Thompson Profile Picture
    6,350 on at
    RE: Infinite Loop Error in Workflows

    So a better trigger would be when the appropriate field in a child record is updated (or a child record is created).

    That would also mean that records are updated in near enough real time rather than 5 minutes later...

  • Community Member Profile Picture
    on at
    RE: Infinite Loop Error in Workflows

    Hello Rawish,

    Thanks for your update.

    I have gone through the provided link. It's suggesting to use Bulk Delete Job for the recurring/scheduling tasks.

    But it seems like the Bulk Delete Job can execute once in a day at a definite time. In our scenario, we want schedule the same every 5 minute (It might be less too).

    Please suggest an alternate approach based on the details provided above.

    Thank you,

  • Community Member Profile Picture
    on at
    RE: Infinite Loop Error in Workflows

    Hello Ben,

    It will not do as the parent and child fields are configurable and will be provided by the user dynamically.

    Also, the fields can be modified/deleted as well.

    Thanks,

  • Community Member Profile Picture
    on at
    RE: Infinite Loop Error in Workflows

    Hello Sreevalli,

    Please know, this is not a 1 time job.  I would like to execute the same workflow logic again and again in the interval of say 5 minutes.

    The parent and child fields are configurable and will be provided by the user dynamically.

    Also, the fields can be modified/deleted as well.

    Thanks

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans