Estimated reading time:
I’m going to start posting about common issues that you might come across when using the Fortis Wrapper for Sitecore.
This first one is something I see very regularly, and its usually a very simple problem to fix.
If we start to look at the stack trace there is an
ArgumentNullException thrown in the constructor of the
FieldWrapper class. The parameter that is null is the
field parameter. That is the
Sitecore.Data.Fields.Field object that the Fortis
SpawnProvider passes into the
FieldWrapper to use as its internal field object. The
FieldWrapper then “wraps” the Sitecore field object and provides properties and methods to get at the values.
The fact that the
Field being passed in is null, usually means that when the Sitecore item was retrieved from the database, the field did not exist on that item.
The first thing to check is that the field exists in the master database on the template that the item is based on. If not, you are probably missing something from the TDS/Unicorn/Sitecore Package or whatever method you use to sync up your databases. So get the field added and publish.
If the field does exist on the template, then it probably has not been published to the web database. Publish that template and you are good to go.
Finally - maybe the field should have been removed from the template. In that case, you haven’t re-generated your Fortis model class since removing that field. If you re-gen the code, it will remove the reference to the field and your site will start working again.
Hopefully this helps someone!