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

时间:2016-03-22 13:45:54

标签: acumatica

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

中使用了以下代码片段 公共PXAction行动; [PXButton] [PXUIField(DisplayName的="操作",MapEnableRights = PXCacheRights.Select,MapViewRights = PXCacheRights.Select)]  protected IEnumerable Action(PXAdapter适配器,            [PXIntList(new int [] {1,2,3},new string [] {" Create Account"," Create Sales order"," Create Invoice" }),PXInt]            诠释? actionId,           [PXString]           string ActionName)       {           if(actionId == 2)           {             //实现So Order行插入处理程序           }           return Base.Action.Press(adapter);       }

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

1 个答案:

答案 0 :(得分: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);
    }
}