Concept is: When I saved the particular record on the investigation screen that "investigationID" field should save in another screen called "Deviation report" (you can see the below images)
investigation screen image
deviation screen image("investigationID" field value storing)
But here, I'm facing the problem when I'm trying to delete the record on the investigation screen that particle "investigationID". The value should become a null on the screen of deviation screen (you can see above image ...> yellow colour marked of "deviation screen")
That related code:
I wrote the code in RowPersisted event (when it is saved this investigationID field should save in deviation screen (you can see in "deviation screen image"...> it is saving):
protected void TSInvestigation_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
{
var row = (TSInvestigation)e.Row;
if (row == null)
return;
if (row.InvestigationCD.Trim() != "<NEW>" /*row.InvestigationCD != null && TSInvestigationView.Cache.GetStatus(row) == PXEntryStatus.Inserted*/)
{
DeviationReportMaint DeviationReportMaintGraph = PXGraph.CreateInstance<DeviationReportMaint>();
DeviationReportMaintGraph.Clear();
//TSInvestigation get = this.TSInvestigationView.Current;
//TSDeviationReport retbatch = DeviationReportMaintGraph.TSDeviationReportView.Insert(new TSDeviationReport());
//TSDeviationReport retbatch = PXSelect<TSDeviationReport>.Select(DeviationReportMaintGraph);
if (row.DeviationDocID != null /*&& get.InvestigationCD != null*/)
{
TSDeviationReport tSDeviation = PXSelect<TSDeviationReport, Where<TSDeviationReport.deviationCD,
Equal<Required<TSDeviationReport.deviationCD>>>>.Select(this, row.DeviationDocID);
if (tSDeviation != null)
{
tSDeviation.InvestigationID = row.InvestigationCD;
DeviationReportMaintGraph.TSDeviationReportView.Update(tSDeviation);
DeviationReportMaintGraph.Actions.PressSave();
//DeviationReportMaintGraph.TSDeviationReportView.Cache.Update(tSDeviation);
//DeviationReportMaintGraph.Actions.PressSave();
}
}
}
}
I wrote the code in RowDeleted event (When I delete the row on the investigation screen that related investigationcd field should become a null value on the "deviation screen" you can see in "deviation screen image")
protected void TSInvestigation_RowDeleted(PXCache cache, PXRowDeletedEventArgs e)
{
var row = (TSInvestigation)e.Row;
if (row == null)
return;
DeviationReportMaint DeviationReportMaintGraph = PXGraph.CreateInstance<DeviationReportMaint>();
DeviationReportMaintGraph.Clear();
//TSInvestigation get = this.TSInvestigationView.Current;
if (row.DeviationDocID != null /*&& get.InvestigationCD != null*/)
{
TSDeviationReport tSDeviation = PXSelect<TSDeviationReport, Where<TSDeviationReport.deviationCD,
Equal<Required<TSDeviationReport.deviationCD>>>>.Select(this, row.DeviationDocID);
if (tSDeviation != null /*|| tSDeviation == null*/)
{
tSDeviation.InvestigationID = null;
DeviationReportMaintGraph.TSDeviationReportView.Update(tSDeviation);
DeviationReportMaintGraph.Actions.PressSave();
}
}
}
But while I'm deleting the record I'm getting this below error:
Getting this error while deleting the record on investigation screen
Where is the mistake in the code?