SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Updating an Item inside a SharePoint 2007 Workflow

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

Comments

ALEX wrote re: Updating an Item inside a SharePoint 2007 Workflow
on 10-24-2007 4:50 PM

THANKS!!!!!!!!!!!!!!!!!!!!!!!!!

Tina wrote re: Updating an Item inside a SharePoint 2007 Workflow
on 11-21-2007 11:29 PM

Hi,

I have an issue here, the update work for some field and does not work for some field, what can it be?

Thanks

Valli wrote re: Updating an Item inside a SharePoint 2007 Workflow
on 07-23-2008 12:56 PM

Hi,

    In this MSDN documentation they say that events are triggered when a SystemUpdate is done. Its under Remarks section. Are these the same events you are talking about?

msdn.microsoft.com/.../ms461526.aspx

Thanks,

Bhuvan.

Kay wrote re: Updating an Item inside a SharePoint 2007 Workflow
on 01-28-2009 2:45 PM

I am thinking outside the box here... but cant you check what raised the update event?  if its a workflow then cancel it......  Just a thought

zakir hossain wrote re: Updating an Item inside a SharePoint 2007 Workflow
on 04-16-2009 5:56 AM

Greate !!!!

It works. Thanks a lot.

Lyudmila wrote re: Updating an Item inside a SharePoint 2007 Workflow
on 06-04-2009 2:11 PM

Thanks a lot... I just forgot about this option...but it was mentioned in one of SharePoint exam question...

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.