Required fields and linking to other lists

Had an interesting problem come up at work the other day.   I had written some custom code that reads from ListA (which has 3 required fields one of which is a lookup into ListB) and outputs them.   Every so often the web part would come back saying that one of the entries was missing a field.   I could not figure out how an entry was being created that did not have all the required fields.  I tried the SharePoint UI and the dataview and both would not let me create the entry without having the required field filled in.

Turns out that you cannot create the entry without the required fields.  However, one of the fields is a lookup into ListB and if that entry is deleted from ListB then the field in ListA that was using that entry is now blank.  I can see why MS did this (and if memory serves this is different than how it worked in 2003) but what a pain figuring it out!

Of course the other option is to check every field to make sure it is not NULL before trying to process it and ignore those entries that were not completebut it was decided that we would not that in this case.

Leave a Reply