How to pass custom field vales from Opportunity to

2019-08-16 05:27发布

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

标签: acumatica
1条回答
手持菜刀,她持情操
2楼-- · 2019-08-16 05:48

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);
    }
}
查看更多
登录 后发表回答