In IAlertNotifyHandler implementation I need name of the user who created/add the current item/document to the list (for which this alert is being sent). What is the way to do this?


When you create your OnNotification method you can access the list item with code similar to this.

public bool OnNotification(SPAlertHandlerParams ahp)


      SPSite site = new SPSite(ahp.siteUrl+ahp.webUrl);

      SPWeb web = site.OpenWeb();

      SPList list=web.Lists[ahp.a.ListID];

      SPListItem item = list.GetItemById(ahp.eventData[0].itemId);

      String user = item("Author");


Not sure on your requirements but you may need to add some additional code to then get a domain\username if this is what you require.

Note: This is sub-optimal code to highlight only the code needed to get the list item. I know there are dispose issues here.

  • @Charles I'm usint SPFieldUserValue oUser = item["Created By"] as SPFieldUserValue;. Will this pose a problem? – TheVillageIdiot Apr 1 '10 at 21:47
  • Not if it works no. Are you getting an appropriate value back? – Charles Lee Apr 2 '10 at 8:46
  • 1
    Remember to dispose SPSite/SPWeb you create yourself – Anders Rask Apr 3 '10 at 17:17
  • I did mention that in my last note, but I suppose its worth another mention in the comments. – Charles Lee Apr 3 '10 at 19:05
  • Definitely @Anders and @Charles i'm opening site and web using using constructs – TheVillageIdiot Apr 4 '10 at 18:28

No Need for Code or anything, Add the Fields Created By and Modified By and you see all.

  • 1
    He needs the info in C#, not in the GUI – Robert Lindgren May 27 '14 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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