II have an event receiver of a list and do some updates in another list in ItemAdded function. since, It does not work for limited access users, so I try to use SPSecurity.RunWithElevatedPrivileges for giving access for such users. But It still does not work for limited access users. I try to log what is going on in my function. shockingly, my ItemAdded function did not work even in the first line(LoLogInfo("event@receiver@ starting!");). I make sure of it because I checked sharepoint log file.What is wrong with me? here is my code:
public override void ItemAdded(SPItemEventProperties properties)
{
LoLogInfo("event@receiver@ starting!");
SPSecurity.RunWithElevatedPrivileges(delegate ()
{
LogInfo("event@receiver@ first step!");
using (SPSite site = new SPSite(properties.SiteId))
{
LogInfo("event@receiver@ second step!");
using (SPWeb web = site.OpenWeb(properties.Web.ID))
{
LogInfo("event@receiver@ third step!");
SPList activeList = web.Lists.TryGetList(properties.List.Title);
SPList finalList = web.Lists[FinalListName];
web.AllowUnsafeUpdates = true;
SPListItem finalListItem = finalList.AddItem();
LogInfo("event@receiver@ forth step!");
//some other code here
web.AllowUnsafeUpdates = false;
}
}
});
}