Please Help Me :|: BPM issue

I wrote this BPM on a Post Event in the OrderMasterUpdate. but some reason it saves my change(s) in the BPM such as the Plant and warehouse Code but if something else change in the Screen it won’t save those changes. What’s preventing to save the changes. If I have disabled the BPM and then I change something on the screen it will take those changes. That leads me to belief that something in my BMP is reversing those changes. please help…

////--------------------------------------------------------------------------------------------------------------------
//// 
////  Notes: 
////   This BPM Combines all the logic for GroundInfo and Plant update.
////  MAIN IDEA:  
////  IMPORTANT: 

////--------------------------------------------------------------------------------------------------------------------
////
//  Created By: M TOLOZA
//  Date Created : 11/14/2019
//  Modifie Created : 11/14/2019
////--------------------------------------------------------------------------------------------------------------------
// TABLES 

//// LOCAL VARIABLES
decimal oneWeight = decimal.Zero;
decimal oneBox = decimal.Zero;
decimal pallet = decimal.Zero;

decimal totalWeight = decimal.Zero;
decimal totalOneBox = decimal.Zero;
decimal totalPallets = decimal.Zero;
int itotalOneBox = 0;
int itotalWeight = 0;

int lOrderNumber = 0;
bool lCheckBox19 = false;
bool lCheckBox20 = false;
string lPlant = "20";
string lWareHouseCode = "CA";

Erp.Tables.OrderRel OrderRel;
Erp.Tables.OrderHed OrderHed;


/// LOCAL VARIABLES
    
Action<int, int, string, string > UpdateOrderGroundInfo = (inOrderNumber, inOrderLine, inPlant, inWarehouseCode) =>
{
  //this.PublishInfoMessage("Updating POST :"  + inOrderNumber.ToString() , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
  // System.Transactions.TransactionScope
 
  
  
  //using (System.Transactions.TransactionScope txScope = IceDataContext.CreateDefaultTransactionScope())
  using (var txScope = IceContext.CreateDefaultTransactionScope())
              {   
              
              ///--- UPDATE Db.OrderHed because  OrderHeaderXRow.CheckBox20 and OrderHeaderXRow.CheckBox19  are not present in the temporary table ttOrderHed Db.OrderRel.With(LockHint.UpdLock) 
              foreach (var DBOrderHed_iterator in (from DBOrderHed_Row in Db.OrderRel
                        where   
                        (int) DBOrderHed_Row.OrderNum == (int) inOrderNumber  &&
                        (int) DBOrderHed_Row.OrderLine == (int) inOrderLine                     
                          select DBOrderHed_Row))
          {
             OrderRel = DBOrderHed_iterator;
            if (OrderRel != null)
            {
              
               OrderRel.Plant = inPlant;
               OrderRel.WarehouseCode = inWarehouseCode; 
                                 
               }
              //Db.OrderRel.Update(OrderRel);
              //Db.Validate();
              
              }  /// END if (DBOrderHed != null)
             txScope.Complete();
            }  /// 
              
              
using (var SalesOrderSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
{
 var SalesOrderDs = SalesOrderSvc.GetByID(inOrderNumber);
this.dsHolder.Attach(SalesOrderDs);
}

};



    
Action<int, decimal, decimal,decimal, bool, bool > UpdateGroundInfo = (inOrderNumber, inTotalWeight, inTotalBoxes, inTotalPallets, inCheckBox19, inCheckBox20) =>
{
  //this.PublishInfoMessage("Updating POST :"  + inOrderNumber.ToString() , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
  // System.Transactions.TransactionScope
 

  //using (System.Transactions.TransactionScope txScope = IceDataContext.CreateDefaultTransactionScope())
  using (var txScope = IceContext.CreateDefaultTransactionScope())
              {   
              
              ///--- UPDATE Db.OrderHed because  OrderHeaderXRow.CheckBox20 and OrderHeaderXRow.CheckBox19  are not present in the temporary table ttOrderHed  Db.OrderHed.With(LockHint.UpdLock) 
              foreach (var DBOrderHeader_iterator in (from DBOrderHed_Row in Db.OrderHed 
                        where   
                        (int) DBOrderHed_Row.OrderNum == (int) inOrderNumber                         
                          select DBOrderHed_Row))
          {
             OrderHed = DBOrderHeader_iterator;
            if (OrderHed != null)
            {              
            OrderHed.Number16 = inTotalWeight ;
            OrderHed.Number17 = inTotalBoxes;
            OrderHed.Number10 =  inTotalPallets; 
            OrderHed.CheckBox19 =  inCheckBox19;  
            OrderHed.CheckBox20 =  inCheckBox20;                                  
               }
             // Db.OrderHed.Update(OrderHed);
              //Db.Validate();
              
              }  /// END if (DBOrderHed != null)
             txScope.Complete();
            }  /// 
              
              
using (var SalesOrderSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
{
var SalesOrderDs = SalesOrderSvc.GetByID(inOrderNumber);
this.dsHolder.Attach(SalesOrderDs);
}


};



    
    
/// HEADER  :::  
    foreach (var OrderHeader_Iterator in (from ttOrderHed_Row in ttOrderHed   
                        select ttOrderHed_Row ))
  {
    var OrderHeaderXRow = OrderHeader_Iterator;
    if (OrderHeaderXRow != null)
      {
      
  
      /// NEED TO JOIN Db.OrderDtl, Db.OrderRel, Db.Part
var jquery = (from OrderH in Db.OrderHed
  join OrderD in Db.OrderDtl on OrderH.OrderNum equals OrderD.OrderNum
  join OrderR in Db.OrderRel on OrderH.OrderNum equals OrderR.OrderNum
  join PartR in Db.Part on OrderD.PartNum equals PartR.PartNum  
  where (          
    (string.Compare(OrderD.Company, callContextClient.CurrentCompany, true ) == 0) &&
    (string.Compare (OrderH.Company, callContextClient.CurrentCompany, true) == 0) &&    
    ( (int)OrderH.OrderNum == (int)OrderHeaderXRow.OrderNum) &&
    ( (int)OrderD.OrderLine == (int)OrderR.OrderLine)       
    )
  
select new {
  Company = OrderH.Company
  ,OrderNum = OrderH.OrderNum
  ,CustNum= OrderH.CustNum
  ,OrderLine   = OrderD.OrderLine
   ,PartsPerContainer = PartR.PartsPerContainer
   ,NetWeight  = PartR.NetWeight
    ,Number11   = PartR.Number11
   ,OurStockQty = OrderR.OurStockQty
   

  }).ToList();

      foreach ( var TT in jquery) {
            //this.PublishInfoMessage("Company:" + TT.OrderLine.ToString()  
            //                    + (string)  " OrderNum:" + TT.OrderNum.ToString()  
            //                     +  " OrderLine:" + TT.OrderLine  
            //                      +  " CustNum:" + TT.CustNum  
            //                       + " PartsPerContainer:" + TT.PartsPerContainer  
            //                        +  " NetWeight:" + TT.NetWeight  
            //                         +   " Number11:" + TT.Number11  
            //                          +   " OurStockQty:" + TT.OurStockQty  
            //                           +   " OrderHeaderXRow.RowMod:" + OrderHeaderXRow.RowMod.ToString()                                         
            //                    , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
        
        
        
            lOrderNumber = TT.OrderNum;
            if (TT.PartsPerContainer == 0)
                    {
                        oneWeight = 1;
                        oneBox = 1;
                    }
           else if (TT.PartsPerContainer > TT.OurStockQty)
                    {
                        oneWeight = (TT.NetWeight / TT.PartsPerContainer) * TT.OurStockQty;
                        oneBox = TT.OurStockQty / TT.PartsPerContainer;                        
                    }
            else
                    {
                        oneWeight = TT.OurStockQty / TT.PartsPerContainer * TT.NetWeight;
                        oneBox = TT.OurStockQty / TT.PartsPerContainer;
                    }
            
            
            if ((decimal)TT.Number11 == 0)
                    {
                        pallet = 1;
                    }                   
            else
                    {
                        pallet = oneBox / (decimal)TT.Number11;
                    }
            
            
            totalWeight = (totalWeight + (decimal) oneWeight);
            totalOneBox = (totalOneBox + (decimal) oneBox);
            totalPallets = (totalPallets + (decimal) pallet);
            lOrderNumber = TT.OrderNum;
            
            
            
            itotalWeight = (int) Math.Round(totalWeight, 0);
            itotalOneBox = (int) Math.Round(totalOneBox, 0);
            
             lCheckBox20 = true;
             lCheckBox19 = false;

            if ((itotalOneBox > 15 || itotalWeight > 110))
              {
                  lCheckBox19 = true;
                  lCheckBox20 = false;
              }
              
 
            
        }  // foreach ( var TT in query)  
      
   
      try{

          OrderHeaderXRow["Number16"] = totalWeight ;
          OrderHeaderXRow["Number17"] = totalOneBox;
          OrderHeaderXRow["Number10"] =  totalPallets; 
          OrderHeaderXRow["CheckBox19"] =  lCheckBox19;  
          OrderHeaderXRow["CheckBox20"] =  lCheckBox20; 
        UpdateGroundInfo (lOrderNumber, totalWeight, totalOneBox, totalPallets, lCheckBox19, lCheckBox20);
          }
      
      catch (Exception ex)
      {
      this.PublishInfoMessage("There was a problem processing your request !"    , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "TTBPM1077", "TTBPM1077");
       }
      
      
     

      
        /// RELEASE  :::  
    foreach (var OrderRelease_Iterator in (from ttOrderHed_Row in ttOrderRel   
                        select ttOrderHed_Row ))
  {
    var OrderReleaseXRow = OrderRelease_Iterator;
    if (OrderReleaseXRow != null)
      {
      
      /// NEED TO JOIN Db.OrderDtl, Db.OrderRel, Db.Part
var rquery = (from OrderH in Db.OrderHed
  join OrderD in Db.OrderDtl on OrderH.OrderNum equals OrderD.OrderNum
  join OrderR in Db.OrderRel on OrderH.OrderNum equals OrderR.OrderNum
  join ShipT in Db.ShipTo on OrderH.ShipToNum equals ShipT.ShipToNum  
  where (          
    (string.Compare(OrderD.Company, callContextClient.CurrentCompany, true ) == 0) &&
    (string.Compare (OrderH.Company, callContextClient.CurrentCompany, true) == 0) &&    
    ( (int)OrderH.OrderNum == (int)OrderHeaderXRow.OrderNum) &&
    ( (int)OrderD.OrderLine == (int)OrderR.OrderLine)  &&
  ( (int)OrderD.CustNum  == (int)ShipT.CustNum )   
    )  
select new {
  HCompany = OrderH.Company
  ,HOrderNum = OrderH.OrderNum
    ,DOrderLine = OrderD.OrderLine
  ,HCustNum= OrderH.CustNum
  ,HOTSState = OrderH.OTSState 
  ,HOTSCountryNum = OrderH.OTSCountryNum
   ,HUseOTS = OrderH.UseOTS 
   ,HShipToNum = OrderH.ShipToNum 
   ,HCheckBox07 = OrderH.CheckBox07 
  ,HCheckBox08 = OrderH.CheckBox08 
  ,HCheckBox19 = OrderH.CheckBox19
  ,HCheckBox20 = OrderH.CheckBox20        
  ,ROrderLine   = OrderD.OrderLine
  ,RCheckBox17   = OrderR.CheckBox17
   ,SState = ShipT.State
    ,SCountry = ShipT.Country
  
  }).ToList();

      
      foreach ( var RR in rquery) {
        //this.PublishInfoMessage("Release " +   RR.OTSState.ToString() , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "TTBPM1078", "TTBPM1078");
        
        /// DO NOT RUN ANY FURTHER IF the following checkboxes are checked
        
        ///
        
        if((bool) RR.HCheckBox07 == false && (bool) RR.HCheckBox08 == false && (bool) RR.RCheckBox17 == false && (RR.HShipToNum.ToString() != "06300" && RR.HShipToNum.ToString() != "1415" )  ){
          //One Time Ship To's
          this.PublishInfoMessage("Running logic : " + RR.HShipToNum.ToString()  , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
          
          if ((bool) RR.HUseOTS == true)
           {
            
            if (
                        RR.HOTSState ==  "AK" ||
                        RR.HOTSState  ==  "AR" ||
                        RR.HOTSState  ==  "AZ" ||
                        RR.HOTSState  ==  "CA" ||
                        RR.HOTSState  ==  "CO" ||
                        RR.HOTSState  ==  "FL" ||
                        RR.HOTSState  ==  "HI" ||
                        RR.HOTSState  ==  "IA" ||
                        RR.HOTSState  ==  "ID" ||
                        RR.HOTSState  ==  "IL" ||
                        RR.HOTSState  ==  "KS" ||
                        RR.HOTSState  ==  "LA" ||
                        RR.HOTSState  ==  "MN" ||
                        RR.HOTSState  ==  "MO" ||
                        RR.HOTSState  ==  "MT" ||
                        RR.HOTSState  ==  "ND" ||
                        RR.HOTSState  ==  "NE" ||
                        RR.HOTSState  ==  "NM" ||
                        RR.HOTSState  ==  "NV" ||
                        RR.HOTSState  ==  "OK" ||
                        RR.HOTSState  ==  "OR" ||
                        RR.HOTSState  ==  "SD" ||
                        RR.HOTSState  ==  "TX" ||
                        RR.HOTSState  ==  "UT" ||
                        RR.HOTSState  ==  "WA" ||
                        RR.HOTSState  ==  "WI" ||
                        RR.HOTSState  ==  "WY" ||
                        ( RR.HOTSCountryNum.ToString() == "2" && (RR.HOTSState ==  "BC" || RR.HOTSState ==  "AB" || RR.HOTSState ==  "YT" || RR.HOTSState ==  "NT" || RR.HOTSState ==  "SK" || RR.HOTSState ==  "NU" || RR.HOTSState ==  "MB" ))
                        )
                       {
                          lPlant = "20";
                          lWareHouseCode = "CA";
                       }
                        
                    if(
                       RR.HOTSState==  "CT" ||
                        RR.HOTSState ==  "DE" ||
                        RR.HOTSState ==  "HM" ||
                        RR.HOTSState ==  "MA" ||
                        RR.HOTSState ==  "MD" ||
                        RR.HOTSState ==  "ME" ||
                        RR.HOTSState ==  "NJ" ||
                        RR.HOTSState ==  "NY" ||
                        RR.HOTSState ==  "PA" ||
                        RR.HOTSState ==  "RI" ||
                        RR.HOTSState ==  "VT" ||
                        ( RR.HOTSCountryNum.ToString() == "2" && (RR.HOTSState ==  "NS"  || RR.HOTSState ==  "ON" ||  RR.HOTSState ==  "QC"  || RR.HOTSState ==  "PE" || RR.HOTSState ==  "NL" || RR.HOTSState ==  "NB" ))
                         
                         )
                       {
                        lPlant = "mfgsys";
                          lWareHouseCode = "PGC";
                       }
                                  
            }  //  END :: if ((bool) RR.UseOTS
          
          
          
          
            if ((bool) RR.HUseOTS == false)
           {
               if (
                        RR.SState ==  "AK" ||
                        RR.SState ==  "AR" ||
                        RR.SState ==  "AZ" ||
                        RR.SState ==  "CA" ||
                        RR.SState ==  "CO" ||
                        RR.SState ==  "FL" ||
                        RR.SState ==  "HI" ||
                        RR.SState ==  "IA" ||
                        RR.SState ==  "ID" ||
                        RR.SState ==  "IL" ||
                        RR.SState ==  "KS" ||
                        RR.SState ==  "LA" ||
                        RR.SState ==  "MN" ||
                        RR.SState ==  "MO" ||
                        RR.SState ==  "MT" ||
                        RR.SState ==  "ND" ||
                        RR.SState ==  "NE" ||
                        RR.SState ==  "NM" ||
                        RR.SState ==  "NV" ||
                        RR.SState ==  "OK" ||
                        RR.SState ==  "OR" ||
                        RR.SState ==  "SD" ||
                        RR.SState ==  "TX" ||
                        RR.SState ==  "UT" ||
                        RR.SState ==  "WA" ||
                        RR.SState ==  "WI" ||
                        RR.SState ==  "WY" ||
                        ( RR.SCountry == "CANADA" && (RR.SState ==  "BC" || RR.SState ==  "AB" || RR.SState ==  "YT" || RR.SState ==  "NT" || RR.SState ==  "SK" || RR.SState ==  "NU" || RR.SState ==  "MB" ))
                        )
                       {
                        lPlant = "20";
                        lWareHouseCode = "CA";
                                                 
                         }  ///if (RR.SState ==  "AK"
              
                       if(RR.SState ==  "CT" ||
                        RR.SState ==  "DE" ||
                        RR.SState ==  "HM" ||
                        RR.SState ==  "MA" ||
                        RR.SState ==  "MD" ||
                        RR.SState ==  "ME" ||
                        RR.SState ==  "NJ" ||
                        RR.SState ==  "NY" ||
                        RR.SState ==  "PA" ||
                        RR.SState ==  "RI" ||
                        RR.SState ==  "VT" ||
         
                        ( RR.SCountry == "Canada" && (RR.SState ==  "NS"  || RR.SState ==  "ON" ||  RR.SState ==  "QC"  || RR.SState ==  "PE" || RR.SState ==  "NL" || RR.SState ==  "NB"  ))
                        )
                       {
                        lPlant = "mfgsys";
                          lWareHouseCode = "PGC";
                       }
                  
              
            }  /// END if ((bool) RR.HUseOTS == false)
            
            
            ///  NOTE: CheckBox19  = LTL and CheckBox20 = Ground
            
           // this.PublishInfoMessage("First :RR.HOTSState=" + RR.HOTSState.ToString() +  " RR.SState=" + RR.SState.ToString()    , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "OrderHeaderXRow ", "OrderHeaderXRow ");
            
             if ( ((bool) lCheckBox20 == true) &&
                        (
                        RR.HOTSState ==  "AL" ||
                        RR.HOTSState ==  "GA" ||
                        RR.HOTSState ==  "IN" ||
                        RR.HOTSState ==  "KY" ||
                        RR.HOTSState ==  "MI" ||
                        RR.HOTSState ==  "MS" ||
                        RR.HOTSState ==  "NC" ||
                        RR.HOTSState ==  "OH" ||
                        RR.HOTSState ==  "SC" ||
                        RR.HOTSState ==  "TN" ||
                        RR.HOTSState ==  "VA" ||
                        RR.HOTSState ==  "WV" ||                         

                        RR.SState ==  "AL" ||
                        RR.SState ==  "GA" ||
                        RR.SState ==  "IN" ||
                        RR.SState ==  "KY" ||
                        RR.SState ==  "MI" ||
                        RR.SState ==  "MS" ||
                        RR.SState ==  "NC" ||
                        RR.SState ==  "OH" ||
                        RR.SState ==  "SC" ||
                        RR.SState ==  "TN" ||
                        RR.SState ==  "VA" ||
                        RR.SState ==  "WV" ) 
                        )
                       {
                    
                    //this.PublishInfoMessage("When Ground :"    , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "OrderHeaderXRow ", "OrderHeaderXRow ");
                     
                        lPlant = "20";
                        lWareHouseCode = "CA";
                         } 
                    
            
            
            
            if (((bool) lCheckBox19 == true) &&
                        (RR.HOTSState ==  "AL" ||
                         RR.HOTSState ==  "GA" ||
                        RR.HOTSState ==  "IN" ||
                        RR.HOTSState ==  "KY" ||
                        RR.HOTSState ==  "MI" ||
                        RR.HOTSState ==  "MS" ||
                        RR.HOTSState ==  "NC" ||
                        RR.HOTSState ==  "OH" ||
                        RR.HOTSState ==  "SC" ||
                        RR.HOTSState ==  "TN" ||
                        RR.HOTSState ==  "VA" ||
                        RR.HOTSState ==  "WV" ||
                        



                        RR.SState ==  "AL" ||
                        RR.SState ==  "GA" ||
                        RR.SState ==  "IN" ||
                        RR.SState ==  "KY" ||
                        RR.SState ==  "MI" ||
                        RR.SState ==  "MS" ||
                        RR.SState ==  "NC" ||
                        RR.SState ==  "OH" ||
                        RR.SState ==  "SC" ||
                        RR.SState ==  "TN" ||
                        RR.SState ==  "VA" ||
                        RR.SState ==  "WV" ) 
                        )
                       {
                    
                    ///this.PublishInfoMessage("When LTL :" +   lCheckBox19.ToString() , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "OrderHeaderXRow ", "OrderHeaderXRow ");
                       lPlant = "mfgsys";
                       lWareHouseCode = "PGC";
                         } 

          
           
           try{
        
        //this.PublishInfoMessage("Plant :" +   lPlant.ToString() + "WarehouseCode :" +   lWareHouseCode.ToString()  , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "OrderHeaderXRow ", "OrderHeaderXRow ");
          OrderReleaseXRow["Plant"] = lPlant;
          OrderReleaseXRow["WarehouseCode"] = lWareHouseCode;
          
          UpdateOrderGroundInfo (RR.HOrderNum, RR.DOrderLine, lPlant, lWareHouseCode);
          }
      
      catch (Exception ex)
      {
      this.PublishInfoMessage("There was a problem processing your request !"    , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "TTBPM1088", "TTBPM1088");
       }
      
      
      
          }  /// if((bool) RR.HCheckBox07 == false 
        }  /// end foreach ( var RR
      
        
      
      } /// if (OrderReleaseXRow != null)
    }  ////foreach (var OrderRelease_Iterator

      

      
      
                
        //this.PublishInfoMessage("TopCall"   + " totalWeight" + totalWeight + " totalOneBox" + totalOneBox  + " totalPallets:" + totalPallets , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
        
        
      }   //  END --- if (OrderHeaderXRow != null     
    }   //  END --- if (OrderHeaderXRow != null

Boy thats a bunch of code to analyze. Are you getting an error? Personally, I’d start breaking it down with debug messages to ensure at each point, your queries\lists are populated with the expected data.

Also, would you mind formatting this for readability?

1 Like
Action<int, int, string, string > UpdateOrderGroundInfo = (inOrderNumber, inOrderLine, inPlant, inWarehouseCode) =>
{
  //this.PublishInfoMessage("Updating POST :"  + inOrderNumber.ToString() , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
  // System.Transactions.TransactionScope
 
  
  
  //using (System.Transactions.TransactionScope txScope = IceDataContext.CreateDefaultTransactionScope())
  using (var txScope = IceContext.CreateDefaultTransactionScope())
              {   
              
              ///--- UPDATE Db.OrderHed because  OrderHeaderXRow.CheckBox20 and OrderHeaderXRow.CheckBox19  are not present in the temporary table ttOrderHed Db.OrderRel.With(LockHint.UpdLock) 
              foreach (var DBOrderHed_iterator in (from DBOrderHed_Row in Db.OrderRel
                        where   
                        (int) DBOrderHed_Row.OrderNum == (int) inOrderNumber  &&
                        (int) DBOrderHed_Row.OrderLine == (int) inOrderLine                     
                          select DBOrderHed_Row))
          {
             OrderRel = DBOrderHed_iterator;
            if (OrderRel != null)
            {
              
               OrderRel.Plant = inPlant;
               OrderRel.WarehouseCode = inWarehouseCode; 
                                 
               }
              //Db.OrderRel.Update(OrderRel);
              //Db.Validate();
              
              }  /// END if (DBOrderHed != null)
             txScope.Complete();
            }  /// 
              
              
using (var SalesOrderSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
{
 var SalesOrderDs = SalesOrderSvc.GetByID(inOrderNumber);
this.dsHolder.Attach(SalesOrderDs);
}

};

Something in piece of Code is reversing the updates from the screen. But it does the update in the function…

Please HELP>>>

Changes made directly to Db.records will not be present in your resulting dataset.

Perform a load of the record var NEWRESULTS =SalesOrderBo.GetByID(OrderNum);

Then resultsHolder.Attach(NEWRESULTS);

I meant to say that something in that piece of code is preventing that changes made on the Screen but it does update the table with the changes in the function, but does not take the changes from the screen

var SalesOrderDs = SalesOrderBO.GetByID(inOrderNumber); when I did the change it says that SalesOrderBO does not exist ?

Yeah I just gave an example of the type. In your code, I see you using the bit above to instanciate a SO BO. So use SalesOrderSvc instead

using (var SalesOrderSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
{
var SalesOrderDs = SalesOrderSvc.GetByID(inOrderNumber);
this.dsHolder.Attach(SalesOrderDs);
}

Chris, are you saying that this piece of code is not good ?

I didnt even see that bit - I would edit your original post using the information from the link that @Jason_Woods supplied so we can read the code.

Could you please attach the code as a file? As I can see Reply editor supports file upload.

@windowsmanager I formatted your code for you, but please make sure in future posts you are doing so or it’s a quick way to get your posts ignored. People are volunteering time to try and help others, don’t make them come to the water to drink it, at least bring some to them.

As mentioned by @SAD and @Hogardy - Direct DB changes are highly frowned upon. You already have a reference to a SO BO there, why not use it proper? If I had to guess what the issue here is - I’d venture to say that your changes to the Db arent flushed yet (Db.Validate) at the time when you do your GetByID(). There actually is no reason to GetByID and Attach in each of those functions - it’s very inefficient. Wait until the end of the entire BPM, Db.Validate() then GetByID and Attach. With all that said - Use the BO!

1 Like

Typically, you would want to do the following steps:

  1. GetByID
  2. Make your changes with the full dataset
  3. Update
  4. Attach (maybe)