如何将自定义字段值从机会传递到销售订单? [英] How to pass custom field vales from Opportunity to sales Order?

查看:93
本文介绍了如何将自定义字段值从机会传递到销售订单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将自定义字段值从机会复制到销售订单,同时将机会转换为销售订单。
我遇到了一个示例代码,将自定义字段从销售订单传递到发货,并且我尝试使用该代码来覆盖创建销售订单操作。
我在OpportunityMaint扩展类中使用的以下代码段

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

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

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

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

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

推荐答案

您将需要覆盖CreateSalesOrder操作。下面是一段代码,我不得不将机会降低到销售订单中。

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

这篇关于如何将自定义字段值从机会传递到销售订单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆