I want to set the default value for the sharepoint's built-in field ArticleStartDate
programmatically. But I am unable to do so. My code is as follows:
SPField articleDate = currentWeb.Fields[FieldNames.ArticleStartDate];
if (articleDate != null)
{
articleDate.DefaultValue = Microsoft.SharePoint.Utilities.SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.Today);
articleDate.Update(true);
}
I debugged the program and found the error at the statement SPField articleDate = currentWeb.Fields[FieldNames.ArticleStartDate];
after executing this statement control directly goes to the Catch()
statemenets and displays the error message only false
. What should I do?