How to pass custom field vales from Opportunity to sales Order?

ぐ巨炮叔叔 提交于 2019-12-25 07:05:32

问题


I have to copy the custom field values from opportunity to sales order while converting the opportunity to sales order. I have come across a sample code to pass custom field from sales order to shipment and I have tried to use the code for overriding the “create sales order” action. The following code snippet I have used in OpportunityMaint extension class

public PXAction action; [PXButton] [PXUIField(DisplayName="Actions",MapEnableRights=PXCacheRights.Select,MapViewRights=PXCacheRights.Select)] protected IEnumerable Action( PXAdapter adapter, [PXIntList(new int[] {1,2,3}, new string[] {"Create Account","Create Sales order","Create Invoice"}),PXInt] int? actionId, [PXString] string ActionName) { if(actionId == 2) { // Implement So Order row insert handler } return Base.Action.Press(adapter); }

The piece of code is not triggering. Looking forward for better solution to implement this option Regards, R.Muralidharan


回答1:


You will need to override the CreateSalesOrder action. Below is a snippet of code where I had to push the opportunity down to the sales order.

public class OpportunityMaint_Extension : PXGraphExtension<OpportunityMaint>
{
    public PXAction<CROpportunity> createSalesOrder;
    [PXUIField(DisplayName = Messages.CreateSalesOrder, MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
    [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntry)]
    public virtual IEnumerable CreateSalesOrder(PXAdapter adapter)
    {
        PXGraph.InstanceCreated.AddHandler<SOOrderEntry>((graph) =>
        {
            graph.RowInserted.AddHandler<SOOrder>((cache, args) =>
            {
                var soOrder = (SOOrder)args.Row;
                var soOrderExt = PXCache<SOOrder>.GetExtension<SOOrderExt>(soOrder);

                foreach (CROpportunity opportunity in adapter.Get())
                {
                    soOrderExt.UsrOpportunityID = opportunity.OpportunityID;
                }
            });
        });
        return Base.createSalesOrder.Press(adapter);
    }
}


来源:https://stackoverflow.com/questions/36156112/how-to-pass-custom-field-vales-from-opportunity-to-sales-order

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!