I have a Projection DAC (HCLEPEmployeeTraining) that only has 3 bound fields (EmployeeID, CourseID, ExpiryDate). What I would like to do is to show the EmployeeID in Rows, value of the CourseID as Columns and ExpiryDate as value in the intersection of EmployeeID and CourseID. This is a Grid and not a PivotTable but basically, I am making a PivotTable from these three columns. I am not using Acumatica’s Pivot Table because I have further developments on this screen. So far, I have added the CourseIDs as Columns dynamically to my grid.
See below screenshot from the Screen columns dynamically are added in my Graph Constructor and Code-behind the Page.Init.
Also, I have written a view Delegate that loops through the existing records and sets the Dynamically Created Columns values from the ExpiryDate. See the below Delegate:
protected IEnumerable HCLemployeeTraining()
{
List<HCLEPEmployeeTraining> result = new List<HCLEPEmployeeTraining>();
PXResultset<HCLEPEmployeeTraining> employeeTrainings = SelectFrom<HCLEPEmployeeTraining>.View.Select(this);
foreach (HCLEPEmployeeTraining employeeTraining in employeeTrainings)
{
var record = result.FirstOrDefault(r => r.EmployeeID == employeeTraining.EmployeeID && r.CourseID == employeeTraining.CourseID);
if (record == null)
{
record = new HCLEPEmployeeTraining
{
EmployeeID = employeeTraining.EmployeeID,
EmployeeCD = employeeTraining.EmployeeCD,
EmployeeName = employeeTraining.EmployeeName,
CourseID = employeeTraining.CourseID,
ExpiryDate = employeeTraining.ExpiryDate
};
result.Add(record);
}
else
{
record.ExpiryDate = employeeTraining.ExpiryDate;
}
// Dynamically assign the ExpiryDate to the appropriate unbound field
string fieldName = $"Course_{employeeTraining.CourseID}";
if (HCLEmployeeTraining.Cache.Fields.Contains(fieldName))
{
//HCLEmployeeTraining.Cache.SetValue(record, fieldName, record.ExpiryDate); // Tested as well
HCLEmployeeTraining.Cache.SetValueExt(record, fieldName, record.ExpiryDate);
}
}
return result;
}
When I trace, I see the engine is looping and assigning the ExpiryDate to the Dynamic Columns as I expect but I am not sure why it is not communicated to UI Presentation layer as it can be seen in the UI screenshot above. I am not getting any errors. Any help is appreciated.