I added a workflow to my document library (with a custom content type) and now my content types event receiver function itemcheckingin doesnt fire. Double checked my xml files and it's being properly refered to and other events (itemupdating, itemadding) are firing. Any ideas?
Have you tried programmtically pulling down a list of Event Receivers using something like SPList.EventReceivers and seeing if the correct events are bound to your receiver? Sometimes the XML files don't show exactly what the database is holding.
-Shaun
Is your list item definitely of the content type that has the registered event handler? It sounds like you might have created a new item of the workflow-containing content type where that content type does not have a handler for the event of interest. I guess I interpret your post as saying that you now have two content types -- one with the workflow and one with the event handler.
I second #SCMcDonnell's suggestion to go straight to the horse's mouth and see what event receivers are registered for your list item and its content type.
EDIT: Oh, I guess I initially missed your claim that other events are firing successfully. That makes my answer less likely. Still, I recommend that you go specifically retrieve the event receivers for the offending list item.
Does the list have force checkout on it?
If it does, then the checkin fires and ItemUpdated as well. See this KB article
http://support.microsoft.com/default.aspx/kb/939307
if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null && properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
{
//This is when the update event is triggered by check-in.
}
else
{
//This is triggered by events other than check-in action.
}
Related
[;]
We have a document-set the event receiver is attached to the ContentType (for Document-Set), the idea is when a new site is created document-Set is created as part of provisioning and the event is attached to the it. We tried attaching event-receiver using (typical) PS script. We can see the event-receiver attached in the SP Manager as well as the (event receiver) count.
The problem is Event receiver (itemupdated) does not trigger when user adds/updates the document within the document-Set.
Eventreceiver triggers when we try to modify documentSet metadata/fields, and when we attach it directly to the list instead of documentSet. The documentSet wraps the class SPFolder so the add/edit document will not trigger the itemUpdated event? Is there any event for when document is added/updated from the documentSet? What am I missing here?
Any pointers will be great help.
regards,
[;]
You need to add event handlers for each content type that can be stored in the document set that you want to handle the events for. For example, if your document set, holds 'Document' content types, you need to add event handlers for the 'Document' content type.
You have attached an event handler to the document set, but not the documents within the document set.
I've made an event handler on a list (with the ID of the custom list) with a feature. I activated the feature, but my Event Handler Code is never called (the ItemAdding method).
My question is if there is something that can tell me if the list I created is really tied up with my Event Handler? I've seen something on CodePlex but it was for MOSS, is there something available for WSS or "out of the box"?
I've found that you can use Sharepoint Manager :
http://www.codeplex.com/spm
You can browse to your list and check under "Event Receiver". If your Event Handler is there, then it should be tied up to your list.
In my case it's there but It's called for whatever reason.. I'll have to investigate on that.
UPDATE :
Well, it seems that when SharePoint raises an exception in an Event Handler, it doesn't write any error message and continue like nothing happened, so be sure to debug line by line to check if all your code is called!
I'm trying to find how a field's value has changed in an ItemUpdating event receiver. The particular field's display name and internal name is Regions.
As soon as ItemUpdating is hit, the value of the Regions field is identical for the following:
properties.AfterProperties["Regions"]
properties.BeforeProperties["Regions"]
properties.ListItem["Regions"].ToString()
I would expect the latter two to contain the old value but surely AfterProperties should be set correctly.
Does anyone know how I can obtain the changed value?
Update: The event handler is attached to a MOSS 2007 publishing Pages list.
I've had a lot of trouble with event handlers on publishing pages libraries. Think it comes from their being other event handlers on there already for publishing. I had better success with updating, can you change to that or do you need the sync event to block the change ?
Are you trying this in a List or Document Library ?
It will work Only on the Doc Lib Please refer to these
MSDN and another on same subject
I have a custom content type with two event handler attached : ItemAdded and ItemAdding.
The first one (ItemAdded) is fired without problem.
But the second one is never fire. I've attached the event using API et declarative way. But nothing change.
Do you have already get the same issue ?
Maybe you can use this tool to check wheather your event receivers are assigned correctly to the list where your content type is used:
http://www.entwicklungsgedanken.de/2008/02/29/tool-eventreceiver-installer-for-sharepoint/
Maybe you have a configuration error in your feature definition.
Look in the Event Logs. Mine, most of the time, will place an error entry in the Application event log.
I'm aware of the event receivers on a list for items added etc. However, I have not found a way to fire code upon the creation of a list.
What I'm trying to do is associate a workflow with a list when the list is created (by the user through the UI).
Anyone any ideas?
thanks.
There are a couple of routes you can take...
You can write your own list definition where you have defined the workflow association - That way all lists created based on your list definition, will contain your workflow on default.
Or... depending on your workflow... write an EventReceiver your attach to all lists of the type you wish to attach your workflow to (can easily be achieved tru a feature) and have your event receiver associate the workflow when the first item is added.
or you can associate the workflow to the contenttype used in the list (your own contenttype you attach to your own list definition or a default SharePoint contenttype)
I don't know the rest of your solution, so it's defficult for me to suggest the best solution for you.
What I (almost) always do, is write my own list definition - That way I can avoid problems like this, now or in the future.
With SharePoint 2010 it is now possible to hook into the list creation event by overriding the ListAdded event in the SPListEventReceiver class.
I usually deploy an extra view page which is set to the default view. When the user creates the list he will be sent to the viewpage which contains the setup in code behind. The view page then calls a method ive created, which changes the default view, removes the setup view and change any navigation node pointing to the setup view.
There is probably no perfect answer to this question because there is no list added event receiver (if memory serves me correct).
I don't know if this is the case, but if you really just needed to register an itemadded (or updated, deleted, etc.) event to any new list, I believe you can register the those events at the site (SPWeb) level and they will fire on any new lists created.