views:

51

answers:

1

Hi...

I'm trying to create a replacement Alert Me notification feature for sharepoint.

I've done most of the hard work. I just need to know the best way to get the changes in a timespan.

I know about the SPChange class, and the list.GetChanges() method. However the only information I can from this is what has been done like "Update"/"Rename" and so on.

I'd like more specific information, like what was created/updated/deleted and by who and so on. Should this be done with the SPAudit class? or am I missing something else?

Thanks

+1  A: 

I would recommend checking out my question here: http://stackoverflow.com/questions/921509/how-to-create-a-daily-summary-alert-for-any-change-in-a-sharepoint-site.

I followed Mark's advice in using the SPAudit framework with a couple of tweaks. I ended up adding some custom SPAudit entries of my own in an event receiver attached to the list. Then, each night a console application runs and reads all of the audit entries for that day to send out the alerts.

It sounds like you may want alerts for only one list so you'll have to do more filtering. Also keep in mind that if you want to know more than basic information (for example: which fields have changed) then you'll need to look at creating your own custom SPAudit entries.

*Edit*

For a custom audit entry, I first created a bean that was serializable. Then you can just serialize the bean containing all of your info from your event receiver into the SPAudit entry:

public static void AddEvent(MyCustomBeanClass e, SPSite site)
{
    StringWriter sw = new StringWriter();
    XmlSerializer xs = new XmlSerializer(typeof(MyCustomBeanClass));
    xs.Serialize(sw, e);
    site.Audit.WriteAuditEvent(SPAuditEventType.Custom, "MyCustomAuditing", sw.ToString());
}

Also, I think this post of mine will help you visualize (1) what the entries look like out of the box and (2) some of the extra processing you will need to do (ex: determining if an item was created).

Kit Menke
Excellent info. A follow-up though - if all I really wanted was information on created/changed items in the list. How would I get the details about the item. Details like name, metadata, or what was changed, from what to what?Is it really necessary to create my own event receiver, and add custom SPAudit entries? And if so, can you point me to some litt. or something which explains this process? - thanks :)
Dynde
If you only want basic info like created date, user, and location then you won't need an event receiver. However, if you want more then you will definitely need an event receiver and custom SPAudit entries. I edited my answer with some more info that will hopefully give you a push in the right direction.
Kit Menke