0

I want to copy everything from one DAC to another DAC. I already followed the one from this thread Thread by Joseph Caruana and this thread Thread by Stan A. And I come up with this code and put it under RowPersisting event.

protected void RoutingOperation_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{

  var row = (RoutingOperation)e.Row;
  if (row != null)
    {
      RoutingOperation line = this.RoutingDetails.Select();
      var rev = (RoutingOperation)this.RoutingDetails.Cache.CreateCopy(line);
      this.RoutingDetailRevs.Cache.Insert(rev);
    }     
}

RoutingOperation is the source DAC, and RoutingOperationRev is the new DAC. RoutingDetails is the data view of RoutingOperation DAC and RoutingDetailRevs is the data view of RoutingOperationRev. But nothing happens.

I tried the one from Thread by Joseph Caruana, and I come up with this code

protected void RoutingOperation_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{      
  var row = (RoutingOperation)e.Row;
  if (row != null)
    {           
      RoutingOperationRev rev = PXCache<RoutingOperationRev>.CreateCopy(this.RoutingDetails.Current);
      this.RoutingDetailRevs.Insert(rev);
    }        
}

I got this error,

An object reference is required for the non-static field, method, or property 'PX.Data.PXCache.CreateCopy(object)'

I am wondering, what did I miss. Thank you in advance

  • Possibly related? [An object reference is required for the non-static field, method, or property](https://stackoverflow.com/questions/498400/cs0120-an-object-reference-is-required-for-the-nonstatic-field-method-or-prop) – waka Jan 29 '18 at 09:10
  • @waka I tried but it doesn't work as well, it just create more errors – Helmi Nandani Jan 29 '18 at 09:36
  • You are getting this exception because this methods signature is `PXCache.CreateCopy(TNode a)`. I think the only solution for you in this case is to write your own Copy Method accepting `RoutingOperation` and returning `RoutingOperationRev` where you will do full copy. – Samvel Petrosov Feb 01 '18 at 15:30
  • I would suggest you try to debug into Acumatica code to identify exactly where the error is occuring. Check Sergei's blog: http://asiablog.acumatica.com/2016/04/debug-acumatica-code.html – Joseph Caruana Feb 08 '18 at 20:50

0 Answers0