简体   繁体   English

无法使用报价屏幕 CR304500 中的操作打开 SO 屏幕 SO301000

[英]Unable to open SO screen SO301000 using Action from Quote screen CR304500

I have created a Action called CREATE SO in Sales Quote screen to create Sales order.我在销售报价屏幕中创建了一个名为 CREATE SO 的操作来创建销售订单。 I am unable to open the sales order screen using this action.我无法使用此操作打开销售订单屏幕。 though the sales order is getting created but the SO screen is not opening while creating the SO.尽管正在创建销售订单,但在创建 SO 时 SO 屏幕未打开。 I am not sure where i am making mistake in my code.我不确定我的代码在哪里出错。 Please suggest.请建议。 Thanks.谢谢。

      #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);
                }
                PXLongOperation.StartOperation(this, () => CreateSalesOrderMethod(quote, QuoteList));
                
                yield return quote;
            }
        }

        //Private Method for Create Sales Order
        public virtual void CreateSalesOrderMethod(CRQuote quote, List<CROpportunityProducts> QuoteList)
        {
            //Base.Save.Press();
            bool var_orderCreated = false;
            bool erroroccured = false;
            string ErrMsg = "";

            SOOrderEntry orderGraphObjet = PXGraph.CreateInstance<SOOrderEntry>();
            SOOrder orderHeaderObject = new SOOrder();
            QuoteMaint currGRPH = PXGraph.CreateInstance<QuoteMaint>();
                        
                BAccount customer = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Current<CRQuote.bAccountID>>>>.Select(this.Base, quote.BAccountID);
                if (customer.Type == "CU")
                {
                    orderHeaderObject.CustomerID = quote.BAccountID;
                }
                else
                {
                    throw new PXException("Business Account not converted to Customer yet"); // THIS ERROR IS ALSO NOT SHOWING WHILE ENCOUNTERING.
                }
                orderHeaderObject.CuryOrderTotal = quote.CuryProductsAmount;
                orderHeaderObject.CuryTaxTotal = quote.CuryTaxTotal;
                orderHeaderObject.OrderDesc = quote.Subject;

                orderHeaderObject = orderGraphObjet.CurrentDocument.Insert(orderHeaderObject);
                orderGraphObjet.CurrentDocument.Current = orderHeaderObject;
                orderGraphObjet.Actions.PressSave();

                orderHeaderObject = orderGraphObjet.CurrentDocument.Current;

                foreach (CROpportunityProducts tran in QuoteList)
                {
                    SOLine transline = new SOLine(); //EMPTY DAC OBJECT

                    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;

                    orderGraphObjet.Transactions.Insert(transline); //INSERT DAC INTO DATAVIEW

                    CROpportunityProductsExt xOppProductExt = PXCache<CROpportunityProducts>.GetExtension<CROpportunityProductsExt>(tran);
                    SOLineExt _soLext = PXCache<SOLine>.GetExtension<SOLineExt>(transline);   // GET DAC ENTENSION

                    _soLext.UsrXSeqID = xOppProductExt.UsrXSequenceID;
                    _soLext.UsrXGroupID = xOppProductExt.UsrXGroupID;
                    _soLext.UsrInternalRemk = xOppProductExt.UsrInternalRemk;   // ASSIGN CUSTOM FIELDS

                    orderGraphObjet.Transactions.Update(transline); // UPDATE DAC OBJECT IN DATAVIEW

                }
                orderGraphObjet.Actions.PressSave();
                var_orderCreated = true;

            //if (orderGraphObjet != null && orderHeaderObject != null)
            if (var_orderCreated)
            {
                orderGraphObjet.Document.Current = orderHeaderObject; // HERE I AM GETTING THE OrderType as well as OrderNbr to open the Document.

                throw new PXRedirectRequiredException(orderGraphObjet, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow };
            }
     }

            #endregion


        }
}

The issue is that the redirection is in the PXLongOperation.问题是重定向在 PXLongOperation 中。 A PXLongOperation starts a separate thread that is not related with the UI. PXLongOperation 启动一个与 UI 无关的单独线程。 In order to solve this you can use the PXCustomInfo structure to talk back with the UI thread after the long operation finishes and thus be able to redirect to the so screen.为了解决这个问题,您可以在长操作完成后使用 PXCustomInfo 结构与 UI 线程对话,从而能够重定向到 so 屏幕。

// PXCustomInfoDefinition
public sealed class SORedirectionCustomInfo: IPXCustomInfo
{
    private PXGraph _OrderGraph;
    public SORedirectionCustomInfo(PXGraph orderGraph)
    {
        _OrderGraph = orderGraph;
    }

    public void Complete(PXLongRunStatus status, PXGraph graph)
    {
        if (status == PXLongRunStatus.Completed && graph is <YourQuoteGraphType>)
        {
            throw new PXRedirectRequiredException(orderGraphObjet, "Document") { Mode = PXBaseRedirectException.WindowMode.NewWindow };
        }
    }
}

// Long Operation Method
public virtual void CreateSalesOrderMethod(CRQuote quote, List<CROpportunityProducts> QuoteList)
{
    // Your code to create SO....
    if (var_orderCreated)
    {
        PXLongOperation.SetCustomInfo(new SORedirectionCustomInfo(orderGraphObjet));
    }
}

This should be able to redirect successfully once the long operation is completed and the order is created.一旦长操作完成并创建订单,这应该能够成功重定向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在销售报价屏幕 CR304500 中创建操作时出错 - Error While Creating Action in Sales Quotes Screen CR304500 在创建装运操作时无法将 UDF 从 SOLine (SO301000) 复制到 SOShipLine(SO302000) - Unable to Copy UDF from SOLine (SO301000) to SOShipLine(SO302000) on Create Shipment Action 从销售报价单创建销售订单时出错 (CR304500) - Error While creating Sales Order from Sales Quote (CR304500) 如何将库存可用性状态添加到自定义网格(如SO301000) - How do I add the Inventory Availability Status to Custom Grid like SO301000 如何扩展项目报价屏幕 (PM304500)? - How do I extend Project Quote Screen (PM304500)? 我们可以为 SO301000 销售订单创建一个新的站点地图,如 Acumatica 中的“测试销售订单”站点地图 - Can we create a new site map for the SO301000 Sales Order like "Test Sales Order" site map in Acumatica 从SO屏幕到PO屏幕填充字段 - Populating fields from SO Screen to PO Screen 无法根据操作事件的销售订单更新销售报价屏幕中的自定义字段 - Unable to Update Custom Field in Sales Quote Screen From Sales Order on an Action Event 将自定义操作添加到账单和调整 (AP301000) 屏幕上操作菜单的特殊文件夹 - Adding custom action to Special Folders of action menu on Bills and Adjustments (AP301000) screen 如何在SO30100屏幕中覆盖操作电子邮件SalesOrder - How to override action Email SalesOrder in SO30100 Screen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM