BPM Help - Add lines to TFO

,

Hi Guys,

I’m trying to write a method directive that will let our guys in goods outwards create a Transfer order shipment pack, enter a TFO number, and then have all the picked lines automatically be created on the shipment but I’m struggling to convince Epicor to save the record.

Here’s my code - its attached post-proc on TransOrderShip.ChangeTFShipHeadTFOrdNum

var ttTFO = (from sh in ttTFShipHead
              where sh.Company == "Eschmann"
             select new {sh.PackNum}).FirstOrDefault();
             
  string sttTTFO = $"ttTFO PackNum:{ttTFO.PackNum} - ipProposedTFOrdNum:{ipProposedTFOrdNum}";
  this.PublishInfoMessage(sttTTFO, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "1", "2");

var pickedLines = (from pl in Db.PartAlloc
                    where pl.PickedQty > 0
                    && pl.TFOrdNum == ipProposedTFOrdNum
                   select new {pl.TFOrdNum, pl.PartNum, pl.DimCode, pl.TFOrdLine, pl.PickedQty}); 


  
  //create the ShipDtl line from the picked TFO line
using(var TransOrderShipSvc = Ice.Assemblies.ServiceRenderer.GetService<TransOrderShipSvcContract>(Db))
{

  foreach(var p in pickedLines)
  {
    string sPickedLines = $"{p.TFOrdNum} - {p.TFOrdLine} - {p.PartNum} - {p.PickedQty}";
    this.PublishInfoMessage(sPickedLines, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "1", "2");
    
	//check if the TFO line exists on another open/unshipped pack
    //ToDo
	

    TransOrderShipTableset ts = this.ds;
    TransOrderShipSvc.GetNewTFShipDtl(ref ts, ttTFO.PackNum);
    var newShipLine =(from sd in ts.TFShipDtl
                        where sd.Company == "Eschmann" 
                        && sd.RowMod == "A" select sd).FirstOrDefault();
                      
    string snewShipLine = $"{newShipLine.PackNum}";
    this.PublishInfoMessage(snewShipLine, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "1", "2");
    newShipLine.TFOrdNum = ipProposedTFOrdNum;
    newShipLine.TFOrdLine = p.TFOrdLine;
    newShipLine.WarehouseCode = "ETECHENG";      
    newShipLine.BinNum = "ENGSHIP";
    newShipLine.PartNum = p.PartNum;
    newShipLine.IUM = p.DimCode;
    newShipLine.OurStockShippedQty = p.PickedQty;
    newShipLine.ShippedQty = p.PickedQty;
    newShipLine.requestdate = System.DateTime.Now; 
    string allocationMessage = "";
    string cMessage = "";
    TransOrderShipSvc.Update(ref ts);
    //this.dsHolder.Attach(ts);
    return;
  }
  
} 

Here’s the error I’m getting.

edit to add i know i got something funky going on with getting and updating the right NewTFShipDtl line (“newShipLine”) at the moment, but i got a return at the bottom so just trying to get it to create one line and save it as a starting point before I deal with that. If i cant save one record then I guess there is no point looping through all the other records i want to create.

Cheers

Andy