Post Method Directive :|: BPM :|: Update OrderHed

I’m kind of new to Epicor. and I have been asked to UPDATE the header of the order to populate the number of boxes in an order. I have the following function that get call in a the Post Method Directive “MasterUpdate”. I have tried different things such as an update the table itselt (DB.Orderhed). but that id not work out. Lately I have tried to call the MasterUpdate method one more time in my BPM but I think I’m missing something. Would you be so kind and review my code to explain me why it does not update. Or tell me how can do update 4 fields that exist in the orderhed this update must be on a Post Method Directive. Thanks in advance for the guidance…

Action<int,int, decimal, decimal,decimal, bool, bool > UpdateGroundInfoNewVersion = (inOrderNumber, inCustNum, inTotalWeight, inTotalBoxes, inTotalPallets, inCheckBox19, inCheckBox20) =>
{
using (var txScope = IceContext.CreateDefaultTransactionScope())
              {   
using (var SalesOrderSvc1 = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db))
      {
      var SOds = SalesOrderSvc1.GetByID(inOrderNumber);
      
      string outStringOne = "" ; 
     string outStringTwo  = "" ; 
    string outStringThree  = "" ; 
    string outStringFour  = "" ; 
    string outStringFive ; 
    string outStringSix = ""  ; 
    bool outStrinBoolOutput = false;
    
      for (int i = 0; i < SOds.OrderHed.Count; i++)
      {
          this.PublishInfoMessage("SOds.OrderHed[i].OrderNum  " +  SOds.OrderHed[i].OrderNum  + "CustNum = " + inCustNum.ToString(), Ice.Common.BusinessObjectMessageType.Information,Ice.Bpm.InfoMessageDisplayMode.Individual, "", ""); 
          SOds.OrderHed[i].OrderComment = "Test";
          SOds.OrderHed[i].RowMod = "U";
          SOds.OrderHed[i]["Number16"] = inTotalWeight;
          //this.PublishInfoMessage("Number16 " + SOds.OrderHed[i]["Number16"].ToString() , Ice.Common.BusinessObjectMessageType.Information,Ice.Bpm.InfoMessageDisplayMode.Individual, "", ""); 

          
      }
      
    
            SalesOrderSvc1.MasterUpdate(true, true, "OrderHed", inCustNum, inOrderNumber, true, out outStrinBoolOutput,  out outStringOne , out outStringTwo, out outStringThree , out outStringFour , out outStringFive , out outStringSix, ref SOds);

      this.dsHolder.Attach(SOds);
     
    
    
        } 

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


};
1 Like

We have a couple of BPM’s on Sales Order Entry and we use this directive:

Also, have you tried turning the Tracing Options on to review when the data is updated?

First of all using MasterUpdate was the correct call. Epicor internally has deprecated Update but it still works. Note that it will be called whenever a Head, Detail, Release is updated. That is why Epicor will pass a variable into the BPM called cTableName so you can add a condition only when its cTableName = “OrderHed”.

Second, You already have access to the data being updated, there is no need to do txScopes and using Services simply right click in your editor and you will see that you have a table called ttOrderHed if you update the values in the PRE.

If you can do it in the PRE Even better, then you can avoid doing dsHolder.Attach and Epicor will have the updates refreshed for you.

Lastly, in your case it looks like you are merely updating user columns, you can keep it simple.

Example:

var orders =
	from tod in ttOrderDtl
	where tod.Updated() || tod.Added()
	select tod;

foreach (var todRow in orders)
{
	todRow["ShortChar10"] = "Hello";
       // todRow.PickListComment = "Lorem ipsum..";
}
1 Like

hasokeric,
This has been a great Explanation about the process. But there is a catch about this. Whenever an EDI order gets enter in the system there is not manual intervention in this process and if I don’t Click to open the other the MasterUpdate" Method Directive would not execute. I can’t trace anything in the app since there is not interaction between the UI and Epicor. Then the question is how else can I call the update an order that was entered via EDI and no one is touching those orders ? The only option left is DataDirective ? is that a valid assuption ?

Thanks MAOLIN