Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Event Receiver with new Items.Add()

$
0
0

Hi,

I have a complex event receiver with ItemUpdated method, where I create new Item to the custom SP List.

I use this code, but after in one minut this new item is deleted from the list, and I dont understand, who is the problem

SPSecurity.RunWithElevatedPrivileges(delegate()
           {
               if (properties.ListTitle == "LIST")
               {
                   string siteUrl = "http://site";
                   using (SPSite site = new SPSite(siteUrl))
                   {
                       using (SPWeb web = site.OpenWeb())
                       {
...

web.AllowUnsafeUpdates = true;
SPListItem newItem= SPlist.Items.Add();
newItem["Name"] = web.EnsureUser(user.LoginName).ID;
newItem["Date"] = "----";
....
newItem.Update();
web.AllowUnsafeUpdates = false;

....
   }
}

Please help!

Thanks,

Mykie



Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>