首页 文章

如何将自定义字段值从Opportunity传递到销售订单?

提问于
浏览
0

我必须将自定义字段值从商机复制到销售订单,同时将商机转换为销售订单 . 我遇到了一个示例代码,用于将自定义字段从销售订单传递到货件,我尝试使用该代码覆盖“创建销售订单”操作 . 我在OpportunityMaint扩展类中使用了以下代码片段

公共PXAction行动; [PXButton] [PXUIField(DisplayName =“Actions”,MapEnableRights = PXCacheRights.Select,MapViewRights = PXCacheRights.Select)]保护IEnumerable Action(PXAdapter适配器,[PXIntList(new int [] {1,2,3},新字符串[ ] {“创建帐户”,“创建销售订单”,“创建发票”}),PXInt] int?actionId,[PXString] string ActionName){if(actionId == 2){//实现So Order行插入处理程序} return Base.Action.Press(adapter); }

这段代码没有触发 . 期待更好的解决方案来实现这个选项问候,R.Muralidharan

1 回答

  • 0

    您需要覆盖CreateSalesOrder操作 . 下面是一段代码,我不得不把机会推到销售订单 .

    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);
        }
    }
    

相关问题