Question

I have a problem with my eventreceiver. It is set to fire on updating item from a list, and works very good when I update that item from Sharepoint's web UI. However I have some code that goes through a list and updates it with new values, and this for some reason doesn't fire the event. Here's the updating code:

            SPListItemCollection listItemCollection = list.GetItems(query);

        foreach(SPListItem item in listItemCollection)
        {

            int itemID = matches.FindIndex(match => match.WebID == item["vG_ID"].ToString());
            if (itemID != -1)
            {
                if (item["vG1"].ToString() != matches[itemID].TeamLeftScore.ToString() ||
                    item["vG2"].ToString() != matches[itemID].TeamRightScore.ToString())
                {
                    item["vG1"] = matches[itemID].TeamLeftScore;
                    item["vG2"] = matches[itemID].TeamRightScore;
                    item.Update();
                }
            }
        }

How do I fix that?

Was it helpful?

Solution

As per Robert's suggestion, the answer to this is that an uncaught exception in the code's execution prevented the event from firing. Since Visual Studio was not catching it, I found it out by going through the ULS logs.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top