views:

438

answers:

0

I have created a custom field in SharePoint that inherits from the SPFieldDateTime:

public class ExpiryDateField : SPFieldDateTime
{
    public ExpiryDateField(SPFieldCollection fields, string fieldName)
        : base(fields, fieldName)
    {
    }
    public ExpiryDateField(SPFieldCollection fields, string typeName, string displayName)
        : base(fields, typeName, displayName)
    {
    }

    public override string GetValidatedString(object value)
    {
        DateTime limit = DateTime.Now.AddYears(2);
        DateTime date = DateTime.Now;
        if (DateTime.TryParse(value.ToString(), out date))
        {
            if (date > limit)
            {
                throw new SPFieldValidationException("Date must not be greater than {0}".Formatted(limit.ToString("dd MMM yyyy")));
            }
        }
        return base.GetValidatedString(value);
    }

This field appears ok on the edit page however I when I try to retrieve the value in the ItemUpdating event on my receiver nothing appears. My reciever code is this:

public override void ItemUpdating(SPItemEventProperties properties)
    {
        StringBuilder sb = new StringBuilder();
        foreach (DictionaryEntry entry in properties.AfterProperties)
        {
            sb.AppendFormat("{0} -- {1}\n\r", entry.Key, entry.Value);

        }
}

The output from this is:

vti_etag -- "{E89E9364-C70F-4AEB-A68E-112AF1CF168A},1"
Keywords -- Keywords
vti_candeleteversion -- true
vti_replid -- rid:{E89E9364-C70F-4AEB-A68E-112AF1CF168A}
vti_canmaybeedit -- true
vti_doclibmodstat -- 0
vti_sourcecontrolcheckedoutby -- sqlmemberprovider:[email protected]
vti_timecreated -- 8/20/2009 11:10:31 AM
ExtranetUrl --
ContentType -- Document
vti_title -- Test Title
vti_sourcecontroltimecheckedout -- 8/20/2009 11:10:31 AM
vti_parserversion -- 12.0.0.6421

In the output there should be a column called ExpiryDate that uses the ExpiryDateField. I have also noticed that it is missing another field. This field is called Description and is based on the inbuilt Note type.

Why are these two fields missing?