Question

How can I open a case and activities after invoice was deleted in code?

  • 29 November 2022
  • 0 replies
  • 72 views

Userlevel 1
Badge

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();
}
}
}

 


0 replies

Be the first to reply!

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved