Value cannot be null. (Parameter 'fromItem') - Customer Shipment Shipped from BPM

When trying to check the Shipped checkbox in Customer Shipment Entry from BPM, below error is coming only for the BPM not on the Customization or Kinetic Layer

Server Side Exception

BPM runtime caught an unexpected exception of 'ArgumentNullException' type.
See more info in the Inner Exception section of Exception Details.

Exception caught in: Epicor.ServiceModel

Error Detail 
============
Correlation ID:  70d55e2d-18aa-4185-b93b-526a8a38d989
Description:  BPM runtime caught an unexpected exception of 'ArgumentNullException' type.
See more info in the Inner Exception section of Exception Details.
Program:  Epicor.ServiceModel.dll
Method:  GetRowCopier
Line Number:  365
Column Number:  17
Original Exception Type:  ArgumentNullException
Server Trace Stack:     at Epicor.Data.BufferCopy.GetRowCopier(Object fromItem, Object toItem, Boolean fullRowCopy) in C:\_releases\ICE\ICE4.2.200.11\Source\Shared\Framework\Epicor.ServiceModel\Data\BufferCopy.cs:line 365
   at Epicor.Data.BufferCopy.Copy[TTypeTo](Object fromItem, TTypeTo& toItem) in C:\_releases\ICE\ICE4.2.200.11\Source\Shared\Framework\Epicor.ServiceModel\Data\BufferCopy.cs:line 189
   at Erp.Services.BO.CustShipSvc.UpdateMaster(CustShipTableset& ds, Boolean doValidateCreditHold, Boolean doCheckShipDtl, Boolean doLotValidation, Boolean doCheckOrderComplete, Boolean doPostUpdate, Boolean doCheckCompliance, Boolean ipShippedFlagChanged, Int32 ipPackNum, Int32 ipBTCustNum, String& opReleaseMessage, String& opCompleteMessage, String& opShippingMessage, String& opLotMessage, String& opInventoryMessage, String& opLockQtyMessage, String& opAllocationMessage, String& opPartListNeedsAttr, String& opLotListNeedsAttr, String& shipCreditMsg, Boolean& cError, Boolean& compError, String& msg, String& opPostUpdMessage, Boolean& updateComplete, Boolean& checkComplianceError, Boolean& changeStatusError, Boolean& checkShipDtlAgain) in C:\_releases\ERP\ERP11.2.200.11\Source\Server\Services\BO\CustShip\CustShip.cs:line 28974
   at Epicor.Customization.Bpm.BO.UpdateMasterImpl.ExecuteBase(UpdateMasterParameters parameters)
   at Epicor.Customization.Bpm.MethodCustomizationBase2`2.RunDirectives(TParam parameters) in C:\_releases\ICE\ICE4.2.200.11\Source\Server\Internal\Lib\Epicor.Customization.Bpm\MethodCustomizationBase2.cs:line 177
   at Epicor.Customization.Bpm.CustomizationBase2`2.Execute(TParam parameters) in C:\_releases\ICE\ICE4.2.200.11\Source\Server\Internal\Lib\Epicor.Customization.Bpm\CustomizationBase2.cs:line 98
   at Epicor.Customization.Bpm.BO.CustShipSvcCustomization.UpdateMaster(CustShipTableset& ds, Boolean doValidateCreditHold, Boolean doCheckShipDtl, Boolean doLotValidation, Boolean doCheckOrderComplete, Boolean doPostUpdate, Boolean doCheckCompliance, Boolean ipShippedFlagChanged, Int32 ipPackNum, Int32 ipBTCustNum, String& opReleaseMessage, String& opCompleteMessage, String& opShippingMessage, String& opLotMessage, String& opInventoryMessage, String& opLockQtyMessage, String& opAllocationMessage, String& opPartListNeedsAttr, String& opLotListNeedsAttr, String& shipCreditMsg, Boolean& cError, Boolean& compError, String& msg, String& opPostUpdMessage, Boolean& updateComplete, Boolean& checkComplianceError, Boolean& changeStatusError, Boolean& checkShipDtlAgain)
   at Erp.Services.BO.CustShipSvcFacade.UpdateMaster(CustShipTableset& ds, Boolean doValidateCreditHold, Boolean doCheckShipDtl, Boolean doLotValidation, Boolean doCheckOrderComplete, Boolean doPostUpdate, Boolean doCheckCompliance, Boolean ipShippedFlagChanged, Int32 ipPackNum, Int32 ipBTCustNum, String& opReleaseMessage, String& opCompleteMessage, String& opShippingMessage, String& opLotMessage, String& opInventoryMessage, String& opLockQtyMessage, String& opAllocationMessage, String& opPartListNeedsAttr, String& opLotListNeedsAttr, String& shipCreditMsg, Boolean& cError, Boolean& compError, String& msg, String& opPostUpdMessage, Boolean& updateComplete, Boolean& checkComplianceError, Boolean& changeStatusError, Boolean& checkShipDtlAgain) in C:\_releases\ERP\ERP11.2.200.11\Source\Server\Services\BO\CustShip\CustShipSvcFacade.cs:line 5384
   at Epicor.Customization.Bpm.BO.GetaNewUD03PostProcessingDirective_CreatePart_EE5EE14C7F2C4D829D97EEB6D8D1C6CC.<>c__DisplayClass7_0.<A001_CustomCodeAction>b__0(CustShipSvcContract CustShipBO)
   at Epicor.Customization.Bpm.DirectiveBase`2.CallService[TService](Action`1 action) in C:\_releases\ICE\ICE4.2.200.11\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.Plugins.cs:line 360
   at Epicor.Customization.Bpm.BO.GetaNewUD03PostProcessingDirective_CreatePart_EE5EE14C7F2C4D829D97EEB6D8D1C6CC.A001_CustomCodeAction()
   at Epicor.Customization.Bpm.BO.GetaNewUD03PostProcessingDirective_CreatePart_EE5EE14C7F2C4D829D97EEB6D8D1C6CC.ExecuteCore(Int32 step)
   at Epicor.Customization.Bpm.DirectiveBase`2.Execute() in C:\_releases\ICE\ICE4.2.200.11\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 330
   at Epicor.Customization.Bpm.DirectiveBase`2.Execute(TParam parameters) in C:\_releases\ICE\ICE4.2.200.11\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 222



Client Stack Trace 
==================
   at Ice.Cloud.ProxyBase`1.CallWithCommunicationFailureRetry(String methodName, ProxyValuesIn valuesIn, ProxyValuesOut valuesOut, RestRpcValueSerializer serializer)
   at Ice.Cloud.ProxyBase`1.CallWithMultistepBpmHandling(String methodName, ProxyValuesIn valuesIn, ProxyValuesOut valuesOut, Boolean useSparseCopy)
   at Ice.Cloud.ProxyBase`1.Call(String methodName, ProxyValuesIn valuesIn, ProxyValuesOut valuesOut, Boolean useSparseCopy)
   at Ice.Proxy.BO.UD03Impl.GetaNewUD03(UD03DataSet ds)
   at Ice.Adapters.UD03Adapter.GetaNewUD03()
   at Ice.UI.App.UD03Entry.Transaction.AdapterGetNew()
   at Ice.UI.Shared.UDSupport.UDSingleViewTransaction.GetNew()

Inner Exception 
===============
Value cannot be null. (Parameter 'fromItem')

Appears to be: null value during a copy operation probably of a BPM parameter ‘fromItem’ during access of UD03 and possibly within a customization. Most of the debugging information is in the trace to get you started, but just a guess with this bit of information.

2 Likes

Error is only coming from the Function and the BPM

Same code is working in Customization and in Kinetic Layer

Clint already told you lol.

Let’s see the code.

Looks like your input object is null on a BufferCopy.

3 Likes

Below is the code

int ReqiPackNum = 137295;
string strMsg = "CustomerShipmentShipped " + ReqiPackNum + " " + DateTime.Now + Environment.NewLine;

int iCustNum = 0 ;

string stropWarnMessage = "" ;
string stropAskMessage = "" ;
string stropStopMessage = "" ;

int lineNum = 0 ;
bool  belongToAnotherPC = false ;
string strpcOutsideMessage = "";

string stropReleaseMessage = "";
string stropCompleteMessage = "" ;
string stropShippingMessage = "";
string stropLotMessage = "";
string stropInventoryMessage = "";
string stropLockQtyMessage = "";
string stropAllocationMessage = "";
string stropPartListNeedsAttr = "";
string stropLotListNeedsAttr = "";
string strshipCreditMsg = "";
bool blncError = false;
bool blncompError = false ;
string strmsg = "";
string stropPostUpdMessage = "";
bool blnupdateComplete = true ; 
bool blncheckComplianceError = false ;
bool blnchangeStatusError = false ;
bool blncheckShipDtlAgain = false ;

this.CallService<Erp.Contracts.CustShipSvcContract>(CustShipBO => {
    Erp.Tablesets.CustShipTableset CustShipTS = CustShipBO.GetByID(ReqiPackNum);
    
    var vtsShipHead = CustShipTS.ShipHead.FirstOrDefault(xRow => xRow.Company == Session.CompanyID && xRow.PackNum == ReqiPackNum);
    if(vtsShipHead != null)
    {
      strMsg += " CustNum: " + vtsShipHead.CustNum + ", ReadyToInvoice: " + vtsShipHead.ReadyToInvoice + Environment.NewLine;
      
      iCustNum = vtsShipHead.CustNum;
      
      vtsShipHead.ReadyToInvoice = true;
      vtsShipHead.RowMod  = "U" ;
    }
    
    CustShipBO.CheckPCBinOutLocation(ref CustShipTS, out lineNum, out belongToAnotherPC, out strpcOutsideMessage);
    
    vtsShipHead = CustShipTS.ShipHead.FirstOrDefault(xRow => xRow.Company == Session.CompanyID && xRow.RowMod == "U");
    
    if(vtsShipHead != null)
    {
      strMsg += " ShipStatus: " + vtsShipHead.ShipStatus + ", ReadyToInvoiceChanged: " + vtsShipHead.ReadyToInvoiceChanged + ", Credit: " + vtsShipHead.CreditCardMessage + Environment.NewLine;
      
      vtsShipHead.ShipStatus = "SHIPPED";
      vtsShipHead.ReadyToInvoiceChanged  = true;
      vtsShipHead.SlipStatus = "SHIPPED";
      vtsShipHead.SendShipment = true;
      vtsShipHead.RowMod = "U";
    }
    
    strMsg += " Bef UpdateMaster " + Environment.NewLine;
    
    CustShipBO.UpdateMaster(ref CustShipTS, false, true, false, true, true, false, true, ReqiPackNum, iCustNum, out stropReleaseMessage, out stropCompleteMessage, out stropShippingMessage, out stropLotMessage, out stropInventoryMessage, out stropLockQtyMessage, out stropAllocationMessage, out stropPartListNeedsAttr, out stropLotListNeedsAttr, out strshipCreditMsg, out blncError, out blncompError, out strmsg, out stropPostUpdMessage, out blnupdateComplete, out blncheckComplianceError, out blnchangeStatusError, out blncheckShipDtlAgain);  
    
    strMsg += " Aft UpdateMaster " + Environment.NewLine;
});

I see no reference to Buffer Copy. You sure this is the offending code?

Also, are you sure that CustShipBO.CheckPCBinOutLocation doesnt clear your RowMod?

4 Likes

CustShipBO.CheckPCBinOutLocation doesn’t clear the RowMod

Tried using BufferCopy. Still getting the same error

int ReqiPackNum = 137299;
string strMsg = "CustomerShipmentShipped " + ReqiPackNum + " " + DateTime.Now + Environment.NewLine;
try
{
  int iCustNum = 0 ;
  
  string stropWarnMessage = "" ;
  string stropAskMessage = "" ;
  string stropStopMessage = "" ;
  
  int lineNum = 0 ;
  bool  belongToAnotherPC = false ;
  string strpcOutsideMessage = "";
  
  string stropReleaseMessage = "";
  string stropCompleteMessage = "" ;
  string stropShippingMessage = "";
  string stropLotMessage = "";
  string stropInventoryMessage = "";
  string stropLockQtyMessage = "";
  string stropAllocationMessage = "";
  string stropPartListNeedsAttr = "";
  string stropLotListNeedsAttr = "";
  string strshipCreditMsg = "";
  bool blncError = false;
  bool blncompError = false ;
  string strmsg = "";
  string stropPostUpdMessage = "";
  bool blnupdateComplete = true ; 
  bool blncheckComplianceError = false ;
  bool blnchangeStatusError = false ;
  bool blncheckShipDtlAgain = false ;
  
  this.CallService<Erp.Contracts.CustShipSvcContract>(CustShipBO => {
      Erp.Tablesets.CustShipTableset CustShipOriginalTS = CustShipBO.GetByID(ReqiPackNum);
      
      Erp.Tablesets.CustShipTableset CustShipTS = new Erp.Tablesets.CustShipTableset();
      var newRow = CustShipTS.ShipHead.NewRow();
      BufferCopy.Copy(CustShipOriginalTS.ShipHead[0], newRow);
      CustShipTS.ShipHead.Add(newRow);
     
      
      var vtsShipHead = CustShipTS.ShipHead.FirstOrDefault(xRow => xRow.Company == Session.CompanyID && xRow.PackNum == ReqiPackNum);
      if(vtsShipHead != null)
      {
        strMsg += " CustNum: " + vtsShipHead.CustNum + ", ReadyToInvoice: " + vtsShipHead.ReadyToInvoice + Environment.NewLine;
        
        iCustNum = vtsShipHead.CustNum;
        
        vtsShipHead.ReadyToInvoice = true;
        vtsShipHead.RowMod  = "U" ;
      }
      
      CustShipBO.CheckPCBinOutLocation(ref CustShipTS, out lineNum, out belongToAnotherPC, out strpcOutsideMessage);
      
      vtsShipHead = CustShipTS.ShipHead.FirstOrDefault(xRow => xRow.Company == Session.CompanyID && xRow.RowMod == "U");
      
      if(vtsShipHead != null)
      {
        strMsg += " ShipStatus: " + vtsShipHead.ShipStatus + ", ReadyToInvoiceChanged: " + vtsShipHead.ReadyToInvoiceChanged + ", Credit: " + vtsShipHead.CreditCardMessage + Environment.NewLine;
        
        vtsShipHead.ShipStatus = "SHIPPED";
        vtsShipHead.ReadyToInvoiceChanged  = true;
        vtsShipHead.SlipStatus = "SHIPPED";
        vtsShipHead.SendShipment = true;
        vtsShipHead.RowMod = "U";
      }
      
      strMsg += " Bef UpdateMaster " + Environment.NewLine;
      
      CustShipBO.UpdateMaster(ref CustShipTS, false, true, false, true, true, false, true, ReqiPackNum, iCustNum, out stropReleaseMessage, out stropCompleteMessage, out stropShippingMessage, out stropLotMessage, out stropInventoryMessage, out stropLockQtyMessage, out stropAllocationMessage, out stropPartListNeedsAttr, out stropLotListNeedsAttr, out strshipCreditMsg, out blncError, out blncompError, out strmsg, out stropPostUpdMessage, out blnupdateComplete, out blncheckComplianceError, out blnchangeStatusError, out blncheckShipDtlAgain);  
      
      strMsg += " Aft UpdateMaster " + Environment.NewLine;
  });
  
  InfoMessage.Publish(Environment.NewLine + strMsg);
}
catch(Exception ex)
{
  InfoMessage.Publish(Environment.NewLine + strMsg + Environment.NewLine + "Error at: " + ex.Message);
}

Does anyone have a fix for this?

Did you validate you had data being returned from the GetByID?

1 Like

Check if the data exists before trying to copy it.

var originalShipHeadRow = CustShipOriginalTS.ShipHead.FirstOrDefault();
if (originalShipHeadRow != null)
{
    var newRow = CustShipTS.ShipHead.NewRow();
    BufferCopy.Copy(originalShipHeadRow, newRow);
    CustShipTS.ShipHead.Add(newRow);
}
else
{
    // Throw error....... 
}

2 Likes

Pretty much was my thinking…

1 Like

Yes, data is returning from the GetByID.

Error is coming when the UpdateMaster is called

@aarong Tried your code. Still getting the same error.

https://www.epiusers.help/t/value-cannot-be-null-fromitem-in-buffercopy-getrowcopier/95077

They are saying error is coming because of the credit card issue
Can someone explain this

You show different pieces of code and not possibly the corresponding error to said code. This makes it difficult to assist in your issue, but I would start by examining that you have actual data present to work with here:

    Erp.Tablesets.CustShipTableset CustShipTS = CustShipBO.GetByID(ReqiPackNum);
    
    var vtsShipHead = CustShipTS.ShipHead.FirstOrDefault(xRow => xRow.Company == Session.CompanyID && xRow.PackNum == ReqiPackNum);
    if(vtsShipHead != null)
    {
      strMsg += " CustNum: " + vtsShipHead.CustNum + ", ReadyToInvoice: " + vtsShipHead.ReadyToInvoice + Environment.NewLine;
      
      iCustNum = vtsShipHead.CustNum;
      
      vtsShipHead.ReadyToInvoice = true;
      vtsShipHead.RowMod  = "U" ;
    }
    // vvv this line looked to be the other error you posted and could have had null data again in your CustShipTS
    CustShipBO.CheckPCBinOutLocation(ref CustShipTS, out lineNum, out belongToAnotherPC, out strpcOutsideMessage);
 

or

      CustShipBO.UpdateMaster(ref CustShipTS, false, true, false, true, true, false, true, ReqiPackNum, iCustNum, out stropReleaseMessage, out stropCompleteMessage, out stropShippingMessage, out stropLotMessage, out stropInventoryMessage, out stropLockQtyMessage, out stropAllocationMessage, out stropPartListNeedsAttr, out stropLotListNeedsAttr, out strshipCreditMsg, out blncError, out blncompError, out strmsg, out stropPostUpdMessage, out blnupdateComplete, out blncheckComplianceError, out blnchangeStatusError, out blncheckShipDtlAgain);  

I stand by my question did you validate you have appropriate DATA in those Tablesets?

As @aarong suggested, I tried using the BufferCopy to fix the error.
Both of my codes are identical except for the fact that one includes Buffer Copy and the other does not.

Tablesets contain the appropriate data. The UpdateMaster is where the error is consistently appearing.