Working in Sitecore 10.2, we have a new site that we've added custom processors to to update fields on item:save that need to be automatically generated. We have a very simple processor that sets a custom Calculated Statistics field to an ISO date (as well as other processors that are likely causing the same issue, but I've been able to replicate the issue with only this one processor in place).
Although the only thing the processor does is set a field value, when it does so, the __Final Renderings field never gets set (so all rendering parameters in the standard values don't show up on the page).
namespace MySite.Project.ItemSaving
{
public class ItemSavingCalculatedStatistics
{
public void OnItemSaving(object sender, EventArgs args)
{
var savingItem = Event.ExtractParameter(args, 0) as Item;
Error.AssertNotNull(savingItem, "No item in parameters");
if (savingItem == null)
{
// not for us
return;
}
if (!savingItem.DescendsFrom(FoundationTemplateConstants.CalculatedStatistics.CalculatedStatisticsTemplateId))
{
return;
}
try
{
var statisticsUpdated = savingItem.Statistics.Updated;
var field = savingItem.Fields[FoundationTemplateConstants.CalculatedStatistics.Fields.CalculatedStatisticsUpdated];
if (field != null) field.Value = DateUtil.ToIsoDate(statisticsUpdated);
}
catch (Exception ex)
{
Log.Error("ItemSavingCalculatedStatistics ERROR...", ex, this);
}
}
}
}
When I disable this processor, the __Final Renderings gets populated as expected; Likewise, when I simply put return
at the very beginning of the processor, it's fine. It's only when we do if (field != null) field.Value = DateUtil.ToIsoDate(statisticsUpdated);
that the page ends up having no Final Renderings.
I tried moving the processor to the very end of item:saving
by naming prefixing the config file with zzz and inserting after the very last processor in the section, but the issue still occurs.