Tag Info

Hot answers tagged

2

Disable Event Firing when you're making the update to the item. See here for an example. Make sure you don't leave the events disabled, though! Wrap the code in a try, catch, finally that ends with re-enabling the events. try { this.EventFiringEnabled = false; // Your updating code... } catch (Exception ex) { // Handle exception } finally { ...


2

From your code it seems you are using the same code for handling ItemAdded on both the lists. So what is happening is on inserting item in 1 list is inserting an item into the second list. And this invokes the event receiver in Second list. Two possibilities. You might have attached the same event receiver 5 times - You can review this using SharePoint ...


2

You can impersonate in the event receiver. Usually, running code under System User is required and it is done using throuth RunWithElevatedPrivileges method, like: Guid siteGuid = properties.SiteId; Guid webGuid = properties.Web.ID; Guid listGuid = properties.ListId; int listItemId = properties.ListItemId; SPSecurity.RunWithElevatedPrivileges(delegate() { ...


2

Firstly there's no value for properties.AfterProperties in the ItemAdded event receiver. You can see in what receivers After- and Before- properties are available here. To get a field's value use properties.ListItem['FieldName']. To synchronize appropriate items in both lists you should have some unique field to search items. If you have Title field as a ...


2

You also need to set properties.Cancel = true; Your final code will look like public override void ItemAdding(SPItemEventProperties properties) { try { //my code SPListItem parentItem = oList.GetItemById(discussionId); SPListItem reply =SPUtility.CreateNewDiscussionReply(parentItem); reply["Body"] = ...


1

You can place code something like as below: public override void ItemAdding(SPItemEventProperties properties) { try { bool allowed = true; if (properties.ListTitle == "List A") { allowed = checkItem(properties); // Place your code for item adding for list A } if (!allowed) { ...


1

In the end I got around this issue by assigning temporary values to the required fields, updating the item, checking it in, then running the above piece of code with the addition of a check out before calling thisitem.update(), then assigning the required fields back to null. Not ideal but it works.


1

they are already updated, thats why the event-receiver is triggered. you can get the item, on which behalf the receiver is running by properties.ListItem (properties-object is received as parameter of the method) however, if you update the item again, you have to be careful. because updating the item again of course triggers the Events again, this ...


1

As others have said, this could be because the event receiver is registered multiple times. But to me, it looks like this is happening because you have this ItemAdded event receiver registered for both the "Jawna" and the "Niejawna" lists and you're basically trying to create copies of items between the two lists. To get around this you should disable event ...


1

You're wrong asserting provider-hosted apps don't allow to handle AppInstalled event. It is absolutely possible. Refer to this documentation: Handle events in apps for SharePoint and to this sample: SharePoint 2013: Create a provider-hosted app that customizes app installation


1

If it's creation of a subsite (SPWeb) you want to catch then you can use SPWebEventReceiver.WebProvisioned But if it's a new SiteCollection then you need to stable a feature to the WebTemplate and then react to the SPFeatureReceiver.FeatureActivated



Only top voted, non community-wiki answers of a minimum length are eligible