SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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; 
share|improve this question
up vote 2 down vote accepted


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

share|improve this answer
But how update in items added elements ? I must loop thro them each one ? – Grzegorz Z Nov 21 '12 at 12:26
No properties.ListItem will give you the ListItem just added... and you can access Author property here! – Arsalan Adam Khatri Nov 21 '12 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 '12 at 20:33
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.. – Arsalan Adam Khatri Nov 21 '12 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 '12 at 6:07

Your Answer


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.