I'm using SP2013 enterprise. I've got an Event Receiver on a task list that fires on itemAdded and itemUpdated. Both ERs do the same thing..they take the Assigned TO alue from the Task list and add it to a custom column on the item on which the workflow ran. EventFiringEnabled is false prior to the executing SystemUpdate on the item. In both I am writing to a Trace Log. After the event receiver fires I see duplicate entries in the Trace Log:
w3wp.exe Information: 0 : eiUpdateItem.ItemUpdated ran as: SHAREPOINT\system on item 15 at 10/17/2016 17:08:30
w3wp.exe Information: 0 : eiUpdateItem.ItemUpdated ran as: SHAREPOINT\system onitem 15 at 10/17/2016 17:08:30
It's not clear to me why this would fire twice.
Secondly, The Assigned To value does not update on the item list when another user, with full control on the site, runs the task. When I run it (the WF publisher) or when another user who has basically Contribute permissions. Here is the code that I'm using in the ItemUpdate routine.
if (taskAssignee != "" & intItemID != 0){
SPSecurity.RunWithElevatedPrivileges(delegate (){
using (SPSite elevatedSite = new SPSite(properties.SiteId)){
using (SPWeb web = elevatedSite.OpenWeb(properties.Web.ID)){
SPList destList = web.GetList("Lists/eInvoice");
SPListItem eItem = destList.GetItemById(intItemID);
try{
SPField f = eItem.Fields.GetField("Assigned To");
string internalName = f.InternalName.ToString();
eItem[internalName] = taskAssignee;
eItem["Editor"] = web.CurrentUser.ID;
EventFiringEnabled = false;
eItem.SystemUpdate();
EventFiringEnabled = true;
}
catch (Exception ex)
{ do something;}
}
}
}Love them all...regardless. - Buddha