1

I have a console application that updates an item's field. The field is updated but it doesn't fire the event receiver attached to itemupdated. The same receiver fires when the item is updated inside a web part. Why?

The code snippet for the console application is:

using (SPSite site = new SPSite("http://myserver"))
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList list1 = web.Lists[listname];
                SPItem item = list1.Items[ID];
                string oldfield1 = "";
                string title1 = item["Title"].ToString();
                if (item[field1] != null)
                    oldfield1 = item[field1].ToString();
                else
                    oldfield1 = "";
                item[field1] = oldfield1 + "f";
                item.Update();
            }
        } 
2

Try to add System.Threading.Thread.Sleep(1000); right after item.Update(); to give the console application time finish executing the call to the event receiver.

Try that and let me know if it works.

More: Sometimes your asynchronous post events ItemAdded ItemUpdated don't run from Console Application

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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