Tuesday, July 15, 2008

Workflow updating current item - infinite loop

I added a dead simple workflow to a calendar list today to try something out. It copies the value from a hidden column (Email To) to a column I added (Attendees). I set the workflow to run when when a new item is added or an item is changed. I didn't think too much but during testing, the page becomes very sluggish and eventually it errors out:

"Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries. "

I eventually came across this post that's exactly the same as my problem. The direct cause of the error is that the CAML query statement gets really big. But why? Then it suddenly hit me, it's because that the workflow is set to run when an item is changed too. Since the workflow updates a column in the current list item, this creates an infinite loop where a new workflow instance is created after another.

This appears to me like a bug. There should be a difference between item changes inside a workflow vs outside of the workflow.

No comments: