I have code that uses the RowInserted event to update specific fields in a newly added grid row for the Employee Timecard screen (EP305000) Details section when the '+' button is pressed. The problem is that after the code updates these fields, I can see in the UI that they've been updated - but when I hit the save button, the row disappears - as if it's not recognized as being added.
Is there a dirty flag that has to be set in order for this additional row to be recognized? If I manually update one of these fields, it then recognizes it and it is added.
Is there something I need to add, like setting a 'dirty flag' to update the grid with this inserted row if purely added through BLC code?
the code:
protected void EPTimecardDetail_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
{
string day = null;
DateTime? date = null;
DateTime? startDate = null;
DateTime? endDate = null;
int? project = null;
int? task = null;
if (isCreateCorrectionFlag == false)
{
//Get the last row's data...
foreach (EPTimecardDetail tca in Base.Activities.Select())
{
if (tca.ProjectID == null) break; //This is to make sure the variables have the last valid row's data and not the newly inserted row's data
day = tca.Day;
date = tca.Date;
project = tca.ProjectID;
task = tca.ProjectTaskID;
var tcae = PXCache<PMTimeActivity>.GetExtension<PMTimeActivityExt>(tca);
startDate = tcae.UsrStartDate;
endDate = tcae.UsrEndDate;
}
//var tcd = (PMTimeActivity)e.Row;
var tcd = (EPTimecardDetail)e.Row;
if (tcd == null) return;
tcd.Date = date;
tcd.Day = day;
var tcde = PXCache<PMTimeActivity>.GetExtension<PMTimeActivityExt>(tcd);
tcde.UsrStartDate = startDate; //tcd.Date;
tcde.UsrEndDate = endDate; //tcd.Date;
tcd.TimeSpent = CalcTimeWorked(tcde);
tcd.ProjectID = project;
tcd.ProjectTaskID = task;
tcd.Summary = "=====";
}
//row.BillableTimeCalc = CalcTimeWorked(row);
}
Per Acumatica support (thanks to them!), the Grid's Mode>AutoInsert property needs to be set to "True". This will allow the grid's auto-inserted row to remain after saving: