I have a task list called Finance Department Tasks on this task list i have created an item updating event receiver which checks if all fields in the task list are filled and then sets the task status to "Completed". Further it sets another field named, finance_department_task_complete="yes" in another list called NewJoiner and then i use item.Update();
but here i get SPListDataValidationException if the task is overdue i.e.(if task due date has already expired) but for normal task whose due dates have not expired the event receiver works without any Exception. Can anyone help? Thanks!
Following is my event receiver code
public override void ItemUpdating(SPItemEventProperties properties)
{
//base.ItemUpdating(properties);
if (Convert.ToString(properties.AfterProperties["TimeKM"]) != "" && Convert.ToString(properties.AfterProperties["EliteUpdated"]) != "")
{
properties.AfterProperties["Status"] = "Completed";
SPFieldLookupValue fldNewJoiner = new SPFieldLookupValue(Convert.ToString(properties.AfterProperties["NewJoiner"]));
/*SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite thissite = new SPSite(properties.Web.Site.ID, properties.Web.Site.Zone))
{
using (SPWeb thisweb = thissite.OpenWeb(properties.Web.ID))
{*/
SPList lstNewJoiner = properties.Web.Lists.TryGetList("New Joiners");
if (lstNewJoiner != null)
{
SPListItem itemNewJoiner = lstNewJoiner.GetItemById(fldNewJoiner.LookupId);
if (itemNewJoiner != null)
{
itemNewJoiner["FinanceDeptTaskComplete"] = "Yes";
//itemNewJoiner.SystemUpdate(false);
try{
itemNewJoiner.Update();
}
catch(Eception ex)
{
}
}
}
/* }
}
});*/
}
}
Following is the Exception which i get