2

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

enter image description here

1 Answer 1

1

Finally i have found the issue! There was a column in the list which i was updating, which had a column validation i removed that validation and found that i'm no longer getting the SPListDataValidationException for items with past dates(overdue).

But Now my question is that, is there a way where in you can disable a column validation at run-time in code and enable it once the item is updated. Something like this

 disablevalidation=false; itemNewJoiner.Update(); disablevalidation=true; 

Because i don't want to completely disable validation on that list column.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.