At Event Receiver Item Adding I must add name of worker which is adding a items to the list.

Here is my code:

SPListItem item = lstOtherList.Items.Add();
item["Kontrakt"] = properties.AfterProperties["Kontrakt1"];
item["Pracownik"] = properties.AfterProperties["Author"];
item["Dzien"] = dzienStart;
item["Procenty"] = properties.AfterProperties["Procenty"];
// item["ID z Czas Pracy Wpisy"] = properties.BeforeProperties["ID"];
dzienStart = dzienStart.AddDays(1.0);

I try Title Author but at Event Receiver it doesn't work and puts spaces. How can I get the user?


I was able to do it using the following code in Item Adding:

item["Pracownik"] = properties.UserDisplayName; 

1 Answer 1



On Item Adding the Author field is still not committed because the Item is not made yet..

A similar question is available here:
How to get current logged user in event receivers?

Or in your case if you decide not to make the event receiver synchronous, you can simply use the Author field in ItemAdded event and update the list item again!

I hope this helps

  • But how update in items added elements ? I must loop thro them each one ?
    – Grzegorz Z
    Nov 21, 2012 at 12:26
  • 1
    No properties.ListItem will give you the ListItem just added... and you can access Author property here! Nov 21, 2012 at 12:28
  • But how to get each items and then add only in items added kilkuosobowa field to each of elements on list which are added in items adding?
    – Grzegorz Z
    Nov 21, 2012 at 20:33
  • 1
    ItemAdding event runs for single Item just before it is added to the List... and It should fire for each Item added to the list.. Nov 21, 2012 at 21:18
  • As I tried it adding me first all elements for example 15 times, and next it"s adds me lookup field in Items Added and add me again 15 new elemens with only one column displays - lookup field. Next column isn't filed. And I want to only in Items Added add to in exist element a lookup field.
    – Grzegorz Z
    Nov 22, 2012 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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