Complex field types are useful for communicating between different systems and allowing, for example, data from an external application to be displayed with relative ease.
Complex field types are field types which contain other types. For example, a “Customer” field could contain, within it, the data for the “Customer ID” and “Customer Name”. The “Address” field could have “House Numer”, “Street”, “State”, “Country” and “Postal Code”.
Complex field types are particularly useful because they make it easy to search and display the data.
Common Problems With Complex Fields
One problem with complex fields is that on paper it is possible for a complex field to contain another complex field. In practice, however, not all applications will support this gracefully and some may struggle to break down the inner complex field and display it correctly.
Other issues occur if there is formatting within a complex field. If there is formatting data stored in the field and your application cannot understand it, then this can create unexpected issues. Fortunately, most of the problems are cosmetic, but they still need to be dealt with.
Service Layers in SharePoint
The most effective solution is to use a service layer in SharePoint to manage the formatting and to handle the processing of the complex field. This is the best way to ensure that your complex fields are handled in exactly the right way, however it is not without issues when it comes to maintenance and overheads since it means that you will need to maintain service-level code. In some cases, using the presentation layer to manage complex fields may be simpler. It depends on the way the SharePoint application is already set up, and what code already exists.
SharePoint has options for encapsulating the complex field’s handling in its own class. This allows you to flatten the external content so that you can then handle it in SharePoint using the Business Data Connectivity Designer.
When Complex Fields Make Sense
Complex fields make sense if you are trying to integrate your SharePoint application with external data. If you are operating the other way around and are gathering the data in SharePoint then there are options that may well be more effective. For example, you can use Custom Field Types, which are built in to SharePoint, to ensure that your data is handled in an efficient, robust and error-free manner. Custom Fields can be collected using forms, and you can control the way they are sorted (for example sorting an address by “City”) quite easily using features that are already built in to SharePoint.
SharePoint forms make it easy to collect and validate data, too, so from the end user point of view your application will be robust and stable, and there is less code that can go wrong compared to if you are trying to process data that belongs to a complex field.
The option to handle complex fields exists, but it is one that should be employed only when it is absolutely necessary to do so.
