This is my scenario:
When someone updates an item and sets a choice field to some value, i should catch the update (updating or updated) event fired and if that value matches some value predefined for me, it should update a datetime field with DateTime.Today value.
But i cannot achieve this. When i click on the OK button in editform.aspx it updates the value, but the event doesn't seems to be fired or it is fired but doesn't update the list.
Does anyone knows where am i going wrong, if i'm missing some code or propertie?
Thanks in advance
My code is:
public override void ItemUpdated(SPItemEventProperties properties)
{
try
{
this.DisableEventFiring();
if (properties.ListItem["Estado Testeo"].ToString() == "Listo para Impresión")
{
//properties.ListItem["Fecha del Test"].Text = "";
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSite = new SPSite(properties.ListItem.Web.Site.ID))
{
using (SPWeb oWeb = oSite.AllWebs[properties.ListItem.Web.ID])
{
SPList oList = oWeb.GetListFromUrl(oWeb.Url + <urlList>);
SPListItem oItm = oList.GetItemById(properties.ListItemId);
oItm["Fecha de Test"] = DateTime.Today;
oItm.Update();
}
}
});
}
else properties.ListItem["Fecha de Test"] = "";
}
catch (Exception ex)
{
properties.ErrorMessage = "Error al intentar modificar la tarea del auditor.\r\n" + ex.Message;
properties.Cancel = true;
}
finally
{
this.EnableEventFiring();
}
}
Regards, Joel Di Rosa