views:

323

answers:

2

I've only recently noticed the Filter element in the definition file for a SharePoint event receiver:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
  <Receivers>
    <Receiver>
      ...
      <Filter />
    </Receiver>
  </Receivers>
</Elements>

The MSDN documentation for the SPEventReceiverDefinition.Filter property says that the value: "represents the filter for the SPListItem object". And includes the following remarks:

"Event handlers are registered at the site or site collection level to implement filtering to respond to list item events. Filtering allows multiple rules to be applied in sequence to limit the size of a list or some other dimension of that list. They are specified in persistent storage as name-value pairs in the form of assignment statements."

My question is: how can I set the value of the Filter? Would you use a CAML <Where> element?

I'm just curious at this stage. I don't have a reason to use this, but saw it and starting wondering. I searched through all event receiver definitions in SharePoint 12 'hive' folders and none had a filter applied.

+2  A: 

Any filtering that I have done in event receivers, I have done in code.

I found a couple of liks that seem to indicate that the filter element is either reserved, or not implemented.

http://msdn.microsoft.com/en-us/library/dd340827(PROT.13).aspx

Maybe in MOSS 2010.

Rhys Jones
There is http://msdn.microsoft.com/en-us/library/ms460929.aspx also. (I can only post one link at a time with my rep :) )
Rhys Jones
Thanks for the links. Interesting. It wouldn't be the first time that the SDK documentation contradicts itself and isn't clear :-)
dariom
I would be very curious to see an example of filtering in code, actually. I mean, using the Filter property that you set in code using the SPEventReceiverDefintion. Do you think you can show one? :)
Philippe
A: 

Ya.. i was also wondering what use we can fetch out of .

Is there something that we can specify the list name or may be as u said CAML. My senerio is an event handler for custom list. Since my project has many custom list, i want my event handler to run for only one secific list.

Let me know if you come up with any ideas.

thanks.

You should think about posting this as a separate question :-) It might be worth trying out some values for the Filter element, but as Rhys Jones points out it doesn't look like this will work in MOSS 2007/WSS 3.0 - if it works, let us know! For your scenario: if you're using content types in your lists, you could associate your event receivers with a content type: http://geekswithblogs.net/glennhaworth/archive/2009/06/05/sharepoint-lists-event-receivers-and-content-types.aspx
dariom