Last week, I had the case where I wanted to update an item in a list inside a workflow process.
Of course, I wrote quickly the following code :
workflowProperties.Item["Status"] = "Archived";
workflowProperties.Item.Update();
So what ? Everything worked well !! ..Until...I wanted to have my workflow starting on the Updated event. And the the workflow crashed.
Why ? Because workflowProperties.Item.Update(); raised another Updated event, and the workflow tried to loop. But because one instance of the same workflow is already running, he didn't agree !
The solution I've found is to use the following code:
workflowProperties.Item.SystemUpdate();
which writes directly the data to the database, without invoking list events. You can even add a flag (true/false) for incrementing the version number.
Hope this help.
Posted
05-24-2007 5:42 PM
by
Unclaimed Blog