Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
1  
if you want a knowledgebase entry you should mark this post as community wiki –  Anders Rask Jan 21 '10 at 7:53
    
done. community wiki. –  Alexey Krasheninnikov Jan 21 '10 at 8:05
add comment

1 Answer 1

up vote 1 down vote accepted

The default (out-of-the-box, with only your receiver running) sequence is ItemUpdating (no filename, id=0), ItemAdding (filename present, id=0), ItemAdded (filename present, id>0).

To determine the sequence for other actions, create a feature using Visual Studio with VSeWSS (which will handily generate all method stubs and register the receiver for you) or a feature with receiver using WSPBuilder and add calls to a private method that would contain logging logic (to log to a list called 'log' with a text field called 'info') like the following:

    private static void LogEventToSPList(SPItemEventProperties properties)
    {
        // 'using' clauses properly dispose of SPSite and SPWeb upon completion.
        using (SPSite s = new SPSite("http://sharepoint"))
        {
            using (SPWeb w = s.RootWeb)
            {
                SPListItem newitem = w.Lists["log"].Items.Add();
                newitem["info"] = string.Format(
                "At {0} {1} occurred on item with ID {2} " +
                "(at url {3}) properties changed "
                +"on behalf of {6} in the list called '{7}' " +
                "changing {4}/{5} properties.", 
                DateTime.Now.ToString(), 
                properties.EventType.ToString(),
                properties.ListItemId.ToString(),
                string.Format("{0}{1}{2}",
                      properties.WebUrl,
                      properties.RelativeWebUrl,
                      properties.AfterUrl), 
                properties.AfterProperties.ChangedProperties.Count,
                properties.BeforeProperties.ChangedProperties.Count,
                properties.UserLoginName,
                properties.ListTitle);
                newitem.Update();
            }
        }
    }
share|improve this answer
1  
The answer is complicated by different ways you can add documents and what events are associated to the files being added. Check event troubleshooting guide here msdn.microsoft.com/en-us/library/aa979520.aspx –  Anders Rask Jan 21 '10 at 8:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.