1

I have created a console app in C# .Net. The app is updating two fields in an item in a list. The list has an eventreceiver and when the item is updated it copy every value from all fields to another item on a different site collection. The ItemUpdated event triggers just fine when I manually updates the item, and all values are copied correctly to the other item.

But when I update item via my console app it saves the new values to the item but it does not trigger the ItemUpdated event on the item?.

From my console app:

item["fieldName"] = value;
item.Update();

What do I need to do to trigger the event?

  • Are you logged in as the SharePoint App Pool account? Or using RunWithElevatedPrivileges in your code? – mannaggia Nov 23 '17 at 17:27
  • The code does not run with elevated privileges. I'm running the app with my administrator account that has full admin rights on the sharepoint portal. – kethor Nov 23 '17 at 17:46
  • for you console app, are u using CSOM / SSOM ? – Eric Nov 24 '17 at 2:24
  • I am using Server Side Object Model. Forgot to mention that the list that stores the item is in two places, different site collections. But it uses the same event receiver. ItemUpdated should be triggered but it doesn't. I've tried with Thread.Sleep(), no luck yet. – kethor Nov 24 '17 at 8:16
0

the items which is created by/ modified by system account, workflow or event receiver will not apply.

  • I'm not sure I know what you mean. – kethor Nov 23 '17 at 18:07
0

if you are using CSOM, do remember to call ClientContext.ExecuteQuery https://msdn.microsoft.com/en-us/library/office/ee539976(v=office.14).aspx

string siteUrl = "http://MyServer/sites/MySiteCollection";

ClientContext clientContext = new ClientContext(siteUrl);
SP.List oList = clientContext.Web.Lists.GetByTitle("Announcements");
ListItem oListItem = oList.Items.GetById(3);

oListItem["Title"] = "My Updated Title.";

oListItem.Update();

clientContext.ExecuteQuery();
  • Is the reason my console app not triggering the ItemUpdated event on the item that it isn't in the sharepoint context somehow? Because when I debug attached to w3w.exe processes nothing happends. – kethor Nov 24 '17 at 8:29

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.