Wednesday, January 14, 2015

Resolved: Save conflict!

I've got the headache for one week when I tried to add a new column into list by ListAdded event receiver. It was through the exception "Save conflict..." and I've tried many ways to fix this issue, but I failed.

{
   list.AddFieldAsXML("field_definition");
   list.Update();
 
   //Resolve here - re-fetch
   list = web.List["ListID"];
   SPField newF = ...
   newF.Title = "New Title";
   newF.Update();
}

I really stuck in the dark hole!

Resolve: Sometime, you should refresh your life by hanging out with your friend or buy a ticket for comedy show. For what? To clean all the troubles, problems and worries about the life. I've never thought about the FETCH until now that the list defninition in the database was changed. To update anything into list, just re-fetch the list! That's all. God save me life!

Gravo!

No comments: