The requirement is to open a released billed case after the related invoice was deleted. I got as far as to open the case but can’t open a completed, billed work item. I am trying to do it with the CRActivityMaint graph and using the Activities view for the update, but the record doesn't change although there are no errors.
This is the case update:
// Acuminator disable once PX1045 PXGraphCreateInstanceInEventHandlers [Justification]
var graphCase = PXGraph.CreateInstance<CRCaseMaint>();
// var ret = CRPMTimeActivity.PK.Find(graphAct, link.TimeActivityNoteID);
var ret = CRCase.PK.Find(graphCase, row.CaseCD);
if (ret != null)
{
if (ret.Released == true)
{
ret.Released = false;
ret.Resolution = "IP";
ret.Status = "O";
graphCase.Case.Current = ret;
graphCase.Case.Update(ret);
if (graphCase.Case.Cache.IsInsertedUpdatedDeleted)
{
using (PXTransactionScope scope = new PXTransactionScope())
{
// Acuminator disable once PX1043 SavingChangesInEventHandlers [Justification]
// Acuminator disable once PX1071 PXActionExecutionInEventHandlers [Justification]
graphCase.Save.Press();
scope.Complete();
}
}
}
}
This is what I tried to update the Activity:
// Acuminator disable once PX1045 PXGraphCreateInstanceInEventHandlers [Justification]
var graphAct = PXGraph.CreateInstance<CRActivityMaint>();
CRPMTimeActivity act = PXSelect<CRPMTimeActivity, Where<CRPMTimeActivity.noteID, Equal<Required<CRPMTimeActivity.noteID>>>>.Select(Base, link.TimeActivityNoteID);
if (act != null)
{
act.Released = false;
act.ApprovalStatus = "CD";
act.Billed = false;
graphAct.Activities.Current = act;
//graphAct.Activities.Cache.SetValueExt<PMTimeActivity.released>(act, act.Released);
//graphAct.Activities.Cache.SetValueExt<PMTimeActivity.approvalStatus>(act, act.ApprovalStatus);
graphAct.Activities.Update(act);
if (graphAct.Activities.Cache.IsInsertedUpdatedDeleted)
{
using (PXTransactionScope scope = new PXTransactionScope())
{
// Acuminator disable once PX1043 SavingChangesInEventHandlers [Justification]
// Acuminator disable once PX1071 PXActionExecutionInEventHandlers [Justification]
graphAct.Save.Press();
scope.Complete();
}
}
}