Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Long story short, I have an event receiver on a list item which listens for the ItemAdded event, makes some additional changes to the newly created item, calls listItem.SystemUpdate() and starts a workflow on that item.

The problem is that, even though I do these things in the same thread, the workflow sometimes sees the list item the way it was right after creation, and goes on using that stale data. My guess is that SystemUpdate doesn't really save the changes to the database, or doesn't do it in a transaction scope, or does it asynchronously. Am I right? If so, how can I force commit the changes to the database?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

ItemAdded is an asynchronous method, that's why. you probably want to modify your data before you create the item (within ItemAdding) and commit it to the database, so your workflow runs on that item's data you've just created/modified.

share|improve this answer
    
Ah, thanks. It looks much cleaner this way, too. –  Mihai Feb 8 '11 at 13:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.