开发者

ErrorCode -2130575305 (0x81020037) in SPItemEventReceiver with ListItem.Update()

I'm new to Sharepoint and I'm currently maintaining an established solution which has a bug. Unfortunately I cannot solve the Problem. I get an SPException with ErrorCode 2130575305 in the ItemAdded event when I try to use the properties.ListItem.Update() Method.

It seems like there is a Problem when updating a item shortly after it is updated?

I tried everything I found on the Internet, from using the "ItemAdding" method over allowunsafeupdates to disableeventfiring, but nothing worked, now I ran out of steam

A little piece of program code:

SPListitem itm = list.GetItems(query).Add();
// all single line of text
itm["property"] = anotheritem["property" + "something" + itm["property"]; 
itm.Update();

and afterw开发者_如何转开发ard in the overridden ItemAdded:

SPListItem itm = properties.ListItem;
itm["anotherproperty"] = "something different";
itm.Update(); // <- this throws the error

The Original Error Message is in German so it won't help you much, but its saying something along "SPException, please press back in your browser and try again", which isn't of any help anyways. Also, I can't use try catch in code as it seems to be some sort of web exception?


Sorry x0n, I couldn't try your answer yesterday. it doesn't work, unfortunately, there is no list in properties, only a listid, and even if I know which list calls the itemadded event and navigate to it through lists["listname"].getitembyid(properties.listitem.id) it won't work. isn't "grapping a fresh copy" exactly what i did by writing splistitem itm = properties.listitem; already? Is there a way to "release" the item on the beginning of the itemAdded and reuse it later?

public override void ItemAdded(SPItemEventProperties properties)
{
SPListItem itm = properties.ListItem;
itm["somefield"] = "sometext";
itm.Update(); // <- error, itm.SystemUpdate() throws the same error btw.
base.ItemAdded(properties);
}

I also read the help on msdn, it only tells me the error but not how to handle it, so it wasn't much helpful.

About brian's answer: if itemadded already is the synchronous call there shouldn't be a problem?


When you receive error codes the best resource is MSDN or google. - http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listitem.update.aspx

The error code means the field is read only, which could mean many things. This could be due to permissions of the executing account or a simple race condition.

SharePoint essentially queues up a lot of changes and therefore you can certainly run into timing issues between the different executing threads. If you are changing an item in a sync event(adding) and then again in the async(added) event I would strongly lean towards rethinking the logic of what you are trying to actually do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜