Tag Info

Hot answers tagged

13

The blog post James's colleague wrote is wrong. If you follow the link he uses you'll see the table for lists he uses is different from the one he references. I use these rules of thumb not to have to look at that post all the time: Never use BeforeProperties. Use properties.ListItem. The properties.ListItem will act as BeforeProperties in an '-ing' ...


9

You're seeing this because RunWithElevated runs the code under the AppPool account of the current web application, but the SPWebApplication itself is stored in the config database, which is handled by a different account (the farm account). You will have to run this Feature at Farm scope in order for it to be able to write to the config database.


9

So, after a few weeks on and off trying to figure this one out, having no luck with any replies on any forum, I just thought I would have a look at how the UI page was doing this. (Why didn't I think of this earlier?!) That's when the property EnableMetadataPromotion showed up. Having this keyword to search for, it didn't take me long to google the missing ...


9

We faced the same problem at work recently. And there are two good options here we've found: 1. Global variable Use SPWeb.Properties or some other SharePoint property bag, and use kind of "global variable" trick: you set this variable to "ON" before the batch is executed, and set it to "OFF" later when the batch is finished. And in your event receivers, ...


8

With the help of MS support, we finally got to the bottom of this issue. It turned out to be related to the content database upgrade (from MOSS 2007 to 2010) that had taken place months before. Ultimately, there was no object model fix for the problem, and the SharePoint product group ended up giving us permission (and code) to modify the content database ...


7

Going back to WSS2/SP2003 it was Event Handler. With WSS3/SP2007 it changed to Event Receiver...there is even a setting on the Web App in CA that let's you enable/disable support for backwards-compatible event handling. In the context of 2010, "event handler" or "event receiver" is one in the same.


7

Form MSDN : SPEventReceiverBase.DisableEventFiring Method Prevents events from being raised. So someone could think that all events are disabled (all items, all events, all receivers). But: How DisableEventFiring / EventFiringEnabled works The setting (DisableEventFiring in 2007 and EventFiringEnabled in 2010) must be for the current event ...


7

You can use this approach - create class: public class DisabledItemEventsScope : SPItemEventReceiver, IDisposable { private readonly bool oldValue; public DisabledItemEventsScope() { oldValue = EventFiringEnabled; EventFiringEnabled = false; } #region IDisposable Members public void Dispose() { ...


6

I had the same problem, and debugged for literally weeks. The solution I ended up with was deleting the elements.xml file that specifies the target of the event receivers, and binding the event receivers to your lists programmatically in the FeatureActivated (and don't forget to detach them in FeatureDeactivating). Hope this helps someone.


6

It is not possible to add event handlers to the user info list. Please see this following thread: http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/81aae5ef-9621-48c5-ad52-706e5d6a0f05 That was me asking the question.


6

I anticipate that your root list has the same event receiver assigned to it, and that causes the recursion. The problem, of course, may be not so obvious, but anyway, to prevent event receiver to fire several times, there is a common practice in SharePoint: just use DisableEventFiring and EnableEventFiring methods. internal void ...


6

Usually in Page_Load or in CreateChildControls you should place the check for IsPostback and load the data only if the page is not in the postback mode. And also, you should load the data in all postback handlers. This way, the data is loaded always and only once per page load. But while this solution will work perfectly for a separated page, things get ...


5

From TechNet, the issue is that using Inherits="TRUE" in the content type definition will ignore XmlDocuments. You must use Inherits="FALSE" and manually add the fields to be inherited.


5

Since you are using ItemAdded in SharePoint 2007 that event is asynchronous and happening after the item is added. Asynchronous means that it will happen "behind the scenes", ie you cant redirect the user to an error page. Instead try to use the ItemAdding if you need to cancel the event and present an error message for the user.


5

You can check the TemplateFeatureId property of the SPList object, to see which feature the list template belongs to. The AssetLibrary feature has ID={4BCCCD62-DCAF-46dc-A7D4-E38277EF33F4} . In a Team Site on the other hand the "Site Assets" is created as a document library in code, using the same template feature as "Shared Documents" ...


5

With SP2010, You can use ItemAdded with Synchronization (instead of ItemAdding) to perform some operations after the item is created but before it is presented to the user. Then you can use if(properties.ListItem.File!=null)to determine if listitem has file associated with it. To make ItemAdded synchronous, you need to set the Synchronization property ...


5

You might be able to differentiate by knowing Content Type of the item being added. You can get Content Type by accessing properties.AfterProperties["ContentTypeId"] As documented here, Document Content Type ID starts with 0x0101 vs Folder's content type id - 0x0120 So your code may look like: SPContentTypeId itemContentType = new ...


5

You have to do following: properties.RedirectUrl = properties.Web.ServerRelativeUrl + "/_layouts/settings.aspx"; properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl; properties.Cancel = true; Or properties.ErrorMessage = "File extension not allowed here"; properties.Status = SPEventReceiverStatus.CancelWithError; ...


5

Your discussion intrigued me and I decided to test it eventually :) I wrote 4 event receivers - ReceiverS1, ReceiverS2, ReceiverA1, ReceiverA2, sync (seq num 100), sync (seq num 101), async (seq num 100), async (seq num 101) accordingly. I added receivers and verified using sharepoint manager that all settings correct. This is code for receivers: ...


5

Ouch! Are you trying to use Word Interop in an event receiver! You should not! This will instantiate Word (the actual application) on the server side and this is a really scary and bad operation! Just don't do it! It's not even supported, but that's not the issue here - you server will eventually fail miserably... Now, on to how to do it! Converting from ...


5

I've always had to handle the concurrency issues. On SP 2010, I've done these things: 1) Set the Synchronization property of your receiver to SPEventReceiverSynchronization.Synchronous. 2) Disable event firing within the receiver methods e.g. this.EventFiringEnabled = false; 3) When working with Properties.ListItem object, check if it's not null before ...


5

Might want to take a look at this article http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.speventreceiverbase.disableeventfiring(v=office.12).aspx Basically, what your looking for is something like this base.DisableEventFiring(); item.update(); base.EnableEventFiring();


5

You basically have to create a custom SPWebEventReceiver and activate your mandatory feature under "WebProvisioned" method, like this: public class YourWebEventReceiver : SPWebEventReceiver { public override void WebProvisioned(SPWebEventProperties properties) { base.WebProvisioned(properties); // Activate your ...


4

If you mean EventReceiver for the feature then you need to attach to the VSSHost process of Visual Studio 2010 which is actually running the code on activation during an F5 deploy. Another approach would be to set the solution to 'no activation' and then attach the debugger to the process after a F5, activate the feature, now it should hit the feature code. ...


4

I would try using SPListList.SystemUpdate() in the event handler. I suspect that you're using SPListItem.Update() at the moment. SystemUpdate() won't change the modified date or user.


4

Navigate to corresponding Elements.xml, and you will notice Receivers element with ListTemplateId attribute, like this: <Receivers ListTemplateId="100"> ... </Receivers> What you need is to use ListUrl attribute instead, and point it to the specific list using provided url. There is a how-to on this on MSDN: ...


4

SharePoint 2010 RTM'd in April 2010. That article is from December 2009, when it was in beta. We're now into SP1, so it wouldn't surprise me if they changed the dispatcher to use w3wp.exe instead of owstimer.exe. Personally, if you know that it runs under either of the two, debug either until you hit breakpoints. I don't reckon it's that much of a deal. ...


4

If the provider you're talking about is set up using web part connections then a post back shouldn't break that link, but you may be breaking the golden rule regarding web part connections which is: The provider should be able to provide the data as early as possible The consumer should use the data as late as possible This is to avoid the race ...


4

welcome to SharePoint Stack Exchange!! It is not possible out of the box, just so that you know! But, your problem was so interesting that I thought of spending couple of hours just to develop a small customization :) So this is how my solution works: The default size of images posted on Newsfeed time-line is 300x300px I developed a custom feature that ...


3

Maybe "Event Handler Explorer" can remove them for you? http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1547 The tool is originally for MOSS 2007, so I think you have to rebuild it with the 14 hive dlls to make it work with SharePoint 2010. I wouldn't removed things directly from the database since it is unsupported.



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