SharePoint 2013 – Exception calling “SystemUpdate” with “0” argument(s): “The file has been modified by DOMAIN\Username on “

I’m trying to update some items in a list and I’m using systemUpdate in my PowerShell to do the update so that workflows and event handlers aren’t kicking off.

$item.SystemUpdate()

For some of the items I’m getting the following error:

Exception calling “SystemUpdate” with “0” argument(s): “The file <filename> has been modified by DOMAIN\Username on <date>”

When I run the same script with a $item.Update() rather than a SystemUpdate all works fine. However this will get a lot of the workflows started. so update is not an option.

Then I tried the SystemUpdate again and it just worked. Hmm, this looks a bit inconsistent.

So how can we make this work better? I can see two options:

1. Collect the error and retry the SystemUpdate when it fails.

2. Collect the error and try the Update when it fails. (accept that workflows migth kick off for this one item

 

I also had a look into the SystemUpdate command and there is a second version of the same command.

$item.SystemUpdate(boolean)

According to this article:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.systemupdate.aspx

Updates the database with changes that are made to the list item without changing the Modified or Modified By fields, or optionally, the item version. 

There is only a small difference between the two versions of the system update command.But maybe this will make the update work better.

 

 

Advertisements

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.