Putting order back on credit hold

,

Hi Epicor community,

I have tried using this code to put order on credit-hold in a Method directive on Post-Processing
I have checked and OrderNum and Company value are passed to Post Processing correctly.

company =    callContextBpmData.Character01;     
ordernum =    (int)callContextBpmData.Number01; 
           
           
           

                      
          foreach (var OrderHedRow in (from OrderHed_Row in Db.OrderHed
                        where  OrderHed_Row.Company == company && OrderHed_Row.OrderNum == ordernum 
                        select OrderHed_Row))
          {
                              custnum = OrderHedRow.CustNum;
                      BTcustnum = OrderHedRow.BTCustNum;
                      
                      
                       foreach (var CustomerRow in (from Customer_Row in Db.Customer
                                      where  Customer_Row.Company == company && Customer_Row.CustNum == BTcustnum 
                                      select Customer_Row))
                                      {                                      
                                        BTcustid = CustomerRow.CustID;
                                      }  
                      this.PublishInfoMessage("BTcustnum : "+ BTcustnum.ToString() + "----custnum : "+ custnum.ToString()+"----BTcustid : "+BTcustid, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "FirstVar","SecondVar");
                     
                     var CMsvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.CreditManagerSvcContract>(Db);
                     Erp.Tablesets.CMOrderHedTableset CMTs = new Erp.Tablesets.CMOrderHedTableset();
                     
                     
                     CMTs = CMsvc.GetOrders(BTcustid);
                     
                     CMOrderHedRow ordersToRemoveHoldFrom = (from ordersOnHold in CMTs.CMOrderHed   where ordersOnHold.OrderNum == ordernum select ordersOnHold).FirstOrDefault();
                                                    
                     ordersToRemoveHoldFrom.CreditHold = true;
                     ordersToRemoveHoldFrom.CreditOverride = false;
                     ordersToRemoveHoldFrom.CreditOverrideLimit = 0;
                     ordersToRemoveHoldFrom.RowMod="U";
                     
                     CMsvc.ChangeOrderCreditHold(ref CMTs);
                     CMsvc.UpdateCMOrderHed(BTcustnum,ref CMTs );
                     
            
           }

And it does not work.

Do you have any suggestions?

Kind Regards,

CreditHold on orders is rather annoying in that it’s not just a true/false thing, it’s a does it differ from the BillTo customer. If the Customer is on Credit Hold, then the order CreditHold is set to FALSE if the order is on Credit Hold. If the Customer is NOT on Credit Hold, the order CreditHold is set to TRUE if the order is on Credit Hold. So you have to look at the Billto (which you already have available) CreditHold in order to tell what value to use on the Order.

1 Like

Hi @MLamkin
The customer (BillTo) is on Credit Hold.
That is why by default the order goes on Credit Hold and then we release it however there are situations that we need to put the order back on Credit Hold and this should be a customized process.

Any idea how to do this through BPM?

I reduced your code down to this, just to test. Works great.

The BO code works fine, you order is somewhere else in the code, and I don’t see it.

  int orderNum = 10000;
  int BTcustNum = 22;
  string BTCustID = "MYCUST";


  var CMsvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.CreditManagerSvcContract>(Db);

  var CMTs = CMsvc.GetOrders(BTCustID);
  
  CMOrderHedRow ordersToRemoveHoldFrom = (from ordersOnHold in CMTs.CMOrderHed   where ordersOnHold.OrderNum == orderNum select ordersOnHold).FirstOrDefault();
                                
  ordersToRemoveHoldFrom.CreditHold = true;
  ordersToRemoveHoldFrom.CreditOverride = false;
  ordersToRemoveHoldFrom.CreditOverrideLimit = 0;
  ordersToRemoveHoldFrom.RowMod="U";
  
  CMsvc.ChangeOrderCreditHold(ref CMTs);
  CMsvc.UpdateCMOrderHed(BTcustNum, ref CMTs );

1 Like

Thank you for your response @klincecum

Your help is much appreciated.
Could you please share the directive that you have used and whether it is post/pre processing?

Kind Regards,

Sales.Update Post

1 Like

Are you sure? Did you refresh or go check? I’ll assume you did, but I gotta ask.

How do you know it didn’t work?

It still shows the green “Credit Override” on the summary tab
I will check again (while I have checked it at least 2 dozen times but it does not hurt)

I will use your code as an example to see if that makes a difference.