I'm trying to modify the Equipment view, to be able to group the records. It groups it correctly with the new code I have modify, but when I insert a new record in the Equipment tab and I still don´t save the record , then I change the tab to Inventory and add a new record and then I change to the Equipment tab the record disappears.
I attach photos so you understand what I mean.
I need help since I have to validate so that the record in memory does not disappear when I change tabs.
I hope you can help me with issue, Thanks in advance
No modified code
with modified code
protected virtual IEnumerable equipment()
{
PXCache cache = Base.Caches[typeof(EquipmentProjection)];
EquipmentProjection filter = (EquipmentProjection)cache.Current;
foreach (PXResult<EquipmentProjection> res in SelectFrom<EquipmentProjection>
.Where<EquipmentProjection.dailyFieldReportId
.IsEqual<DailyFieldReport.dailyFieldReportId.FromCurrent>>
.AggregateTo<GroupBy<EquipmentProjection.timeCardCD>>.View.Select(Base))
{
EquipmentProjection equipment = res;
yield return equipment;
}
yield return filter;
cache.IsDirty = false;
}
Acumatica cannot handle a editable view that uses aggregation if I understand correctly. But for future reference you can use a PXDelegateCacheResult to make sure that the records get stored properly in the cache and do not dissapear.
protected virtual IEnumerable equipment()
{
var result = new PXDelegateCacheResult();
var items = SelectFrom<EquipmentProjection>
.Where<EquipmentProjection.dailyFieldReportId
.IsEqual<DailyFieldReport.dailyFieldReportId.FromCurrent>>
.AggregateTo<GroupBy<EquipmentProjection.timeCardCD>>
.View.Select(Base)
foreach (PXResult<EquipmentProjection> res in items)
{
EquipmentProjection equipment = res;
result.Add(equipment);
}
return result;
}