I'm trying to do some treatement after creating an item but the treatement is done twice because in my code after creating the item, I'm updating it , so the event reciever get fired twice: first when I add the element and the second when I updated it. Here's the code :
if (Mode == OperationMode.New)
{
item = ListeActions.AddItem();
item["Client"] = new SPFieldLookupValue(myClient.ID, myClient["Name"] as string).ToString();
//the Event Reciever ItemAdded is fired here
}
if (Mode == OperationMode.Edit)
{
item = ListeActions.GetItemById(ActionItemID);
}
TextField ACObject = (TextField)Page.GetControlById("ACObjectID");
UserField ACAssignedTo = (UserField)Page.GetControlById("ACAssignedToID");
NoteField ACDetails = (NoteField)Page.GetControlById("ACDetailsID");
item["Object"] = ACObject.Value;
item["AssignedTo"] = ACAssignedTo.Value;
item["Details"] = ACDetails.Value;
item.Update();
//if we're in the case of adding new item then the event
//reciever ItemAdded is fired here for the second time
//while ItemUpdated is not fired
So how can I stop the second fire of itemAdded resulting on the item.Update() yet keep the first fire since I need to keep applying my treatement?
PS: in the case of updating an existing ListeActions.item the itemUpdated is fired twice too !!
BTW : This Code isn't written in the itemadded method nor in the itemupdated method, actually it's the code in a user control for a webpart development.