Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a list "Modification Log".Then a workflow for ADD and EDIT.How Can I get "Deleted By" like "Created By" and "Modified By".Please help to have a solution for delete also. This is my code

private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e) {

        SPWeb oSPWeb = workflowProperties.Web;

        oSPWeb.AllowUnsafeUpdates = true;

        SPList oSPList = oSPWeb.Lists["Modification Log"];

        SPListItem oSPListItem = workflowProperties.Item;

        SPListItem oSPListItm = oSPList.Items.Add();

        oSPListItm["Project Code"] = oSPListItem["Project Code"];

        oSPListItm["Project Details"] = oSPListItem["Project Details"];

        oSPListItm["Resource Name"] = oSPListItem["Resource Name"];

        oSPListItm["Department"] = oSPListItem["Department"]; 

        if (Convert.ToString(oSPListItem["Modified By"]) != string.Empty)

        {
            oSPListItm["Operation Done By"] = oSPListItem["Created By"];

            oSPListItm["Operation"] = "ADD";
        }

        else

        {
            oSPListItm["Operation Done By"] = oSPListItem["Modified By"];

            oSPListItm["Operation"] = "EDIT";
        }

        oSPListItm.Update();

        oSPWeb.AllowUnsafeUpdates = false;
    }
share|improve this question
add comment

1 Answer

If you really want to get a log of all events in the list you should look on the audit capabilities in SharePoint. There's a ready infrastructure for it but you have to write code to enable it and to view the reports. See the details here. It's about MOSS 2007 but it works identically in all the editions of SharePoint 2007 and 2010. It allows to view the delete events among many others.

share|improve this answer
    
I would add that while the reports and user interface for setting auditing up are not very good, the API is fairly well built. –  Andy Burns Mar 6 '12 at 12:19
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.