Acumatica 根据销售报价创建销售订单时出错(CR304500)

Acumatica 根据销售报价创建销售订单时出错(CR304500),acumatica,acumatica-kb,Acumatica,Acumatica Kb,我在Sales Quote(CR304500)屏幕中创建了一个名为“CREATE SO”的操作来创建销售订单。我已经创建了一个组合框udf“销售订单类型”,用于选择要创建的销售订单的“单据类型” 当我选择DocType为“SO”时,它的给出错误为“Unit” 缺少转换”。(见图) 当我选择任何其他DocType时,它会给出一个错误“RevisionID” 不能为空。“(参见图) “SO”是SO首选项中的默认订单类型。我无法使用调试器跟踪错误。请建议。谢谢下面是我的代码 #reg

我在Sales Quote(CR304500)屏幕中创建了一个名为“CREATE SO”的操作来创建销售订单。我已经创建了一个组合框udf“销售订单类型”,用于选择要创建的销售订单的“单据类型”

  • 当我选择DocType为“SO”时,它的给出错误为“Unit” 缺少转换”。(见图)

  • 当我选择任何其他DocType时,它会给出一个错误“RevisionID” 不能为空。“(参见图)

  • “SO”是SO首选项中的默认订单类型。我无法使用调试器跟踪错误。请建议。谢谢下面是我的代码

           #region Create Sales Order
    
            public PXAction<CRQuote> createSalesOrder;
            [PXUIField(DisplayName = "Create SO", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Update)]
            [PXProcessButton(CommitChanges = true)]
            public IEnumerable CreateSalesOrder(PXAdapter adapter)
            {
                QuoteMaint graphObject = PXGraph.CreateInstance<QuoteMaint>();
    
                foreach (CRQuote quote in adapter.Get())
                {
                    //Create resultset for Quote Details
                    PXResultset<CROpportunityProducts> PXSetLine = PXSelect<CROpportunityProducts,
                    Where<CROpportunityProducts.quoteID,
                    Equal<Required<CROpportunityProducts.quoteID>>>>.Select(this.Base, quote.QuoteID);
                    List<CROpportunityProducts> QuoteList = new List<CROpportunityProducts>();
                    foreach (CROpportunityProducts line in PXSetLine)
                    {
                        QuoteList.Add(line);
                    }
                  
                    bool var_orderCreated = false;
                    bool erroroccured = false;
                    string ErrMsg = "";
    
                    SOOrderEntry orderGraphObjet = PXGraph.CreateInstance<SOOrderEntry>();
                    SOOrder orderHeaderObject = new SOOrder();
                    QuoteMaint currGRPH = PXGraph.CreateInstance<QuoteMaint>();
                    CRQuoteExt _quoteExt = PXCache<CRQuote>.GetExtension<CRQuoteExt>(quote); 
                    var Extension = this.Base.GetExtension<QuoteMaint_Extension>();
    
                    orderHeaderObject = orderGraphObjet.CurrentDocument.Insert(orderHeaderObject);
                    BAccount customer = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Current<CRQuote.bAccountID>>>>.Select(this.Base, quote.BAccountID);
                    if (customer.Type == "CU")
                    {
                        orderHeaderObject.CustomerID = quote.BAccountID;
                        orderHeaderObject.CustomerLocationID = quote.LocationID;
                    }
                    else
                    {
                        throw new PXException("Business Account not converted to Customer yet");
                    }
                    if (quote.CuryProductsAmount != 0)
                    {
                        orderHeaderObject.CuryOrderTotal = quote.CuryProductsAmount;
                    }
                    else
                    {
                        throw new PXException("Total cannot be 0");
                    }
                    orderHeaderObject.CuryOrderTotal = quote.CuryProductsAmount;
                    orderHeaderObject.CuryTaxTotal = quote.CuryTaxTotal;
                    orderHeaderObject.OrderDesc = quote.Subject;
                    orderHeaderObject.OrderType = _quoteExt.UsrOrderNbr;
    
                    orderGraphObjet.Document.Update(orderHeaderObject);
    
    
                    orderGraphObjet.CurrentDocument.Current = orderHeaderObject;
                    orderGraphObjet.Actions.PressSave();
    
                    orderHeaderObject = orderGraphObjet.CurrentDocument.Current;
    
                    foreach (CROpportunityProducts tran in QuoteList)
                    {
                        SOLine transline = new SOLine();
    
                        orderGraphObjet.Transactions.Insert(transline);
                        transline.OrderNbr = orderHeaderObject.OrderNbr;
                        transline.BranchID = orderHeaderObject.BranchID;
                        transline.InventoryID = tran.InventoryID;
                        transline.TranDesc = tran.Descr;
                        transline.UOM = tran.UOM;
                        transline.OrderQty = tran.Quantity;
                        transline.SiteID = tran.SiteID;
                        transline.CuryUnitPrice = tran.CuryUnitPrice;
                        transline.CuryExtPrice = tran.CuryExtPrice;
                        transline.CuryLineAmt = tran.CuryAmount;
    
                        CROpportunityProductsExt xOppProductExt = PXCache<CROpportunityProducts>.GetExtension<CROpportunityProductsExt>(tran);
                        SOLineExt _soLext = PXCache<SOLine>.GetExtension<SOLineExt>(transline); 
                        _soLext.UsrXSeqID = xOppProductExt.UsrXSequenceID;
                        _soLext.UsrXGroupID = xOppProductExt.UsrXGroupID;
                        _soLext.UsrInternalRemk = xOppProductExt.UsrInternalRemk;
                        orderGraphObjet.Transactions.Update(transline);
    
                    }
                    orderGraphObjet.Actions.PressSave(); //This is the line where both the error is showing
                        
                    if (orderGraphObjet != null && orderHeaderObject != null)
                    {
                        orderGraphObjet.Document.Current = orderHeaderObject;
                        throw new PXRedirectRequiredException(orderGraphObjet, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow };
                    }
    
    
                    yield return quote;
                }
            }
    
    
    ############## DAC FIELD #####################
        [PXDBString(50)]
            [PXUIField(DisplayName = "Sales Order Type")]
            [PXDefault()]
            [PXStringList(new string[] { "SO", "SP", "SS" }, new string[] { "SO - Sales Order", "SP - Sales Of Project", "SS - Sales Of Service" })]
            public virtual string UsrOrderNbr { get; set; }
            public abstract class usrOrderNbr : PX.Data.BQL.BqlString.Field<usrOrderNbr> { }
    
    
    #地区创建销售订单
    公开销售订单;
    [PXUIField(DisplayName=“Create SO”,MapEnableRights=PXCacheRights.Update,MapViewRights=PXCacheRights.Update)]
    [PXProcessButton(CommitChanges=true)]
    公共IEnumerable CreateSalesOrder(PXAdapter适配器)
    {
    QuoteMaint graphObject=PXGraph.CreateInstance();
    foreach(适配器中的CRQuote.Get())
    {
    //为报价详细信息创建结果集
    PXResultset PXSetLine=PXSelect.Select(this.Base,quote.QuoteID);
    List QuoteList=新列表();
    foreach(PXSetLine中的CROpportunityProducts行)
    {
    添加报价表(行);
    }
    bool var_orderCreated=false;
    bool errorOccursed=false;
    字符串ErrMsg=“”;
    SOOrderEntry orderagraphhobjet=PXGraph.CreateInstance();
    SOOrder orderHeaderObject=new SOOrder();
    quoteMain currGRPH=PXGraph.CreateInstance();
    CRQuoteExt-uquoteext=PXCache.GetExtension(quote);
    var Extension=this.Base.GetExtension();
    orderHeaderObject=OrderGraphHobJet.CurrentDocument.Insert(orderHeaderObject);
    BAccount customer=PXSelect.Select(this.Base,quote.BAccountID);
    如果(customer.Type==“CU”)
    {
    orderHeaderObject.CustomerID=quote.BAccountID;
    orderHeaderObject.CustomerLocationID=quote.LocationID;
    }
    其他的
    {
    抛出新的PXException(“尚未转换为客户的业务帐户”);
    }
    如果(quote.CuryProductsAmount!=0)
    {
    orderHeaderObject.CuryOrderTotal=quote.CuryProductsAmount;
    }
    其他的
    {
    抛出新的PXException(“总计不能为0”);
    }
    orderHeaderObject.CuryOrderTotal=quote.CuryProductsAmount;
    orderHeaderObject.CuryTaxTotal=quote.CuryTaxTotal;
    orderHeaderObject.OrderDesc=quote.Subject;
    orderHeaderObject.OrderType=_quoteText.UsrOrderNbr;
    ordergraphhobjet.Document.Update(orderHeaderObject);
    OrderGraphBobJet.CurrentDocument.Current=orderHeaderObject;
    orderagraphhobjet.Actions.PressSave();
    orderHeaderObject=OrderGraphHobJet.CurrentDocument.Current;
    foreach(引用列表中的CROpportunityProducts tran)
    {
    SOLine transline=新SOLine();
    OrderGraphHobJet.Transactions.Insert(音译);
    transline.OrderNbr=orderHeaderObject.OrderNbr;
    transline.BranchID=orderHeaderObject.BranchID;
    transline.InventoryID=tran.InventoryID;
    transline.TranDesc=trans.Descr;
    transline.UOM=trans.UOM;
    transline.OrderQty=运输数量;
    transline.SiteID=tran.SiteID;
    transline.CuryUnitPrice=tran.CuryUnitPrice;
    transline.CuryExtPrice=tran.CuryExtPrice;
    transline.CuryLineAmt=trans.CuryAmount;
    CROpportunityProductsExt xOppProductExt=PXCache.GetExtension(tran);
    SOLineExt _soLext=PXCache.GetExtension(transline);
    _soLext.UsrXSeqID=xopproductext.UsrXSequenceID;
    _soLext.UsrXGroupID=xopproductext.UsrXGroupID;
    _soLext.UsrInternalRemk=xopproductext.UsrInternalRemk;
    orderagraphhobjet.Transactions.Update(音译);
    }
    orderagraphhobjet.Actions.PressSave();//这是显示两个错误的行
    if(orderGraphHobJet!=null&&orderHeaderObject!=null)
    {
    OrderGraphBobJet.Document.Current=orderHeaderObject;
    抛出新的PXRedirectRequiredException(orderGraphObjet,“文档”){Mode=PXBaseRedirectException.WindowMode.NewWindow};
    }
    收益回报报价;
    }
    }
    ##############DAC场#####################
    [PXDBString(50)]
    [PXUIField(DisplayName=“销售订单类型”)]
    [PXDefault()]
    [PXStringList(新字符串[]{“SO”、“SP”、“SS”},新字符串[]{“SO-销售订单”、“SP-项目销售”、“SS-服务销售”})]
    公共虚拟字符串UsrOrderNbr{get;set;}
    公共抽象类usrOrderNbr:PX.Data.BQL.BqlString.Field{}
    


    我建议在将新对象插入缓存时,插入一个已输入关键元素的对象。例如,我将向orderHeaderObject添加CustomerID和CustomerLocationID,然后将其插入文档缓存。当您这样做时,Acumatica验证将启动,并且在您尝试编辑文档之前,将在文档中设置所有默认值。线级对象也是如此,我认为这就是为什么会出现这两个错误的原因