Hi all
We just upgraded from 9.3 to 9.4.14.
After (no problem before) the upgrade our templates now throws an exception due to the following line: ,
@Model.Item.GetString("Title")
First I thought it was due to me inserting a null into the template so i tried the following:
var title = Model.Item.GetString("Title") ?? string.Empty;
@title
But that still did not fix the issue.
When expection the decompiled code its clear that it is done on purpose:
public ItemFieldViewModel GetField(string systemName)
{
ItemFieldViewModel itemFieldViewModel = this.Fields.FirstOrDefault<ItemFieldViewModel>((Func<ItemFieldViewModel, bool>) (f => string.Equals(f.SystemName, systemName, StringComparison.OrdinalIgnoreCase)));
if (itemFieldViewModel != null)
return itemFieldViewModel;
throw new Exception(string.Format("A field with the name {0} does not exist", (object) systemName));
}
Right now I'm left with a clumpsy extensive workaround:
var hasTitle = Model.Item.Fields.Any(s=> s.SystemName.Equals("Title", StringComparison.InvariantCultureIgnoreCase));
var title = hasTitle ? Model.Item.GetString("Title") : string.Empty;
@title
My question is WHY? It have always been that you could do a get string and worst case would be that you get an empty string.
Regards
Simon Nordahl