Skip to main content

Notifications

Announcements

No record found.

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

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

    You could try the following and let me know how it goes.

    You could achieve what you want with two workflows and an action (or this could also be a workflow).

    01. First workflow will trigger on create of the record, it is not a child workflow - This will start the recurring workflow.

    ScreenClip-_5B00_106_5D00_.png

    This workflow first sets the execution time for the First RUN on a field as show below and starts the actual recurring workflow

    ScreenClip-_5B00_106_5D00_.png

    02. Actual recurring workflow will look something similar to the following

    ScreenClip-_5B00_105_5D00_.png

    Its a child workflow, it waits until the execution time, runs the business logic - in this case using an Action but like i said before you can change this to a workflow. Once the logic is executed, it will then set the next execution time using the same approach as above and then starts the new instance of the same.

    Hope it helps

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

    That’s actually right. Totally lost this from my mind. The bulk delete is minimum 1 days job.

    Honestly i cant think of any other way apart from creating a console application. And somehow doing logic there.

    If you were dynamics 365 online - we could have thought of using flow or azure functions.

    But i have heard you can use flow for even microsoft 365 onpremise by installing some data adapter( i would suggest you do some further digging on that approach and also i am not sure if it can same powerfull as online in onpremise)

  • 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

  • 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 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,

  • 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 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,

  • 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,

  • 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.

  • 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.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans