I am using Sitecore 9.3 with Glass Mapper 5.8.177 and component A/B testing does not work for me.
I set up a simple component that works perfectly fine until I begin creating variants for A/B testing of this component. For both variants I am getting the "Data source is invalid." error. I saw this was an issue previously and there were some PR that was merged saying that this was fixed in the version I am using but it still does not seem to be working for me.
The problematic method is:
var datasource = MvcContext.GetDataSourceItem<T>();
which returns null
.
After debugging it seems that the item is resolved correctly until the ItemVersionCountByRevisionTask, void Execute(ObjectConstructionArgs args)
method is reached.
The condition below fails because the Revision field does not exist in the Item Fields
if (scContext != null
&& options != null
&& options.VersionCount
&& scContext.Item != null
&& scContext.Item.Fields[FieldIDs.Revision].GetValue(allowStandardValue: false).IsNullOrEmpty())
{
args.Result = null;
}
Debugger shows that the scContext.Item.Fields
do not contain the Revision field, that is why it returns null
. The only field which is visible in my item while debugging is "__Originator"-{F6D8A61C-2F84-4401-BD24-52D2068172BC}
. There are also no custom fields mapped as well.
I tried setting A/B testing also for different components - the same issue for all of them. All of the components inherit from StandardTemplate and Revision field is present on the items when I check that from Sitecore. Also, all of the components are being displayed and are working fine as long as no A/B testing is used.
When I check MvcContext.DataSourceItem
value after MvcContext.GetDataSourceItem<T>()
; it seems that the items were set correctly in the DataSourceItem
, they are just unable to be mapped to a model.
Any ideas on what is happening here and how to resolve these issues would be more than welcome.