Add Invoice Misc Charge BPM

I’m having any issue trying to add a misc charge to AR Invoice Line after its been added.

I can get the Charge to added without an amount by using BufferCopy on the InvcHead, but I’m pretty sure I need to use Buffer Copy on the InvcMisc table instead. When I try setting the original row though I keep getting Out of Index Error.

using (var txScope = IceContext.CreateDefaultTransactionScope()) 
{   
  var AR = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ARInvoiceSvcContract>(Db);
  
  //Get Invoice Dataset
  var ards = AR.GetByID(invoiceNum);
  
  //Create BufferCopy
  var origRow = ards.InvcHead.NewRow();
  BufferCopy.Copy(ards.InvcHead[0],origRow);
  ards.InvcHead.Add(origRow);
  
  //Add New Misc Charge
  AR.GetNewInvcMisc(ref ards,invoiceNum, invoiceLine);
  AR.OnChangeofMiscCode(invoiceNum,invoiceLine,seqNum,miscCode, ref ards);
  AR.OnChangeofMiscAmt(invoiceNum,invoiceLine,seqNum,miscAmt, ref ards); //Can Enter a Misc Value, but doesn't carry through to Invoice Line

  ards.InvcHead[0].RowMod = "U";

  AR.Update(ref ards);
  //AR.UpdateMaster(ref ards,groupID,table,pF,pF,ref pF,pF,invoiceNum,invoiceLine,empty,pF,totalCharges,pF, out totalCharges, out empty, out empty, out pF);
  
  Db.Validate();
  txScope.Complete();
  AR.Dispose();
}


// Alternate Code.   Feel like it should look something more like this
using (var txScope = IceContext.CreateDefaultTransactionScope()) 
{   
  var AR = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ARInvoiceSvcContract>(Db);
  
  //Get Invoice Dataset
  var ards = AR.GetByID(invoiceNum);
  
  //Create BufferCopy
  var origRow = ards.InvcMisc.NewRow();
  BufferCopy.Copy(ards.InvcMisc[0],origRow); //Receive OUT OF INDEX ERROR
  ards.InvcMisc.Add(origRow);
  
  //Add New Misc Charge
  AR.GetNewInvcMisc(ref ards,invoiceNum, invoiceLine);
  AR.OnChangeofMiscCode(invoiceNum,invoiceLine,seqNum,miscCode, ref ards);
  AR.OnChangeofMiscAmt(invoiceNum,invoiceLine,seqNum,miscAmt, ref ards);

  ards.InvcMisc[0].RowMod = "A";

  AR.Update(ref ards);
  //AR.UpdateMaster(ref ards,groupID,table,pF,pF,ref pF,pF,invoiceNum,invoiceLine,empty,pF,totalCharges,pF, out totalCharges, out empty, out empty, out pF);
  
  Db.Validate();
  txScope.Complete();
  AR.Dispose();
}