How to pass line item custom field value to sales order from opportunity?

后端 未结 2 565
故里飘歌
故里飘歌 2021-01-26 04:57

I have a custom line number field in opportunity product tab for customer to re-sequence the selected products and the grid is sorted on custom field value.

I am trying

2条回答
  •  走了就别回头了
    2021-01-26 05:39

    wish they could split up the call to create the order and the call to insert the lines to make it easier to customize. We have done something similar. Here is a sample from what I tested using a graph extension and overriding the DoCreateSalesOrder call in the opportunitymaint graph. (This assumes the select on products is the same order the transaction on the sales order were inserted. I am sure there could be a better answer, but this is an example I have handy.)

    public class CROpportunityMaintExtNV : PXGraphExtension
    {
        [PXOverride]
        public virtual void DoCreateSalesOrder(Action del)
        {
            try
            {
                del();
            }
            catch (PXRedirectRequiredException redirect)
            {
                var products = this.Products.Select().ToArray();
    
                int rowCntr = 0;
                foreach (SOLine soLine in ((SOOrderEntry)redirect.Graph).Transactions.Select())
                {
                    // Assumes inserted rows in same order as products listed (default should be the key)
    
                    //Current product
                    CROpportunityProducts currentProduct = products[rowCntr];
                    var productExtension = currentProduct.GetExtension();
    
                    ((SOOrderEntry) redirect.Graph).Transactions.Cache.SetValueExt(soLine, productExtension.UsrLineNo);
    
                    rowCntr++;
                }
    
                throw redirect;
            }
        }
    }
    

    The problem you had with your code is the Current product was always the same which resulted in the same value.

提交回复
热议问题