【问题标题】:Page does not reload when complete and action完成和操作时页面不会重新加载
【发布时间】:2015-11-05 20:53:54
【问题描述】:

我在 SO303000 中自定义了操作发布。这是我从 SOInvoiceEntry 复制的代码和我添加的代码:

    [PXUIField(DisplayName = "Release", Visible = false)]
    [PXButton()]
    public IEnumerable Release(PXAdapter adapter)
    {
        List<ARRegister> list = new List<ARRegister>();
        foreach (ARInvoice ardoc in adapter.Get<ARInvoice>())
        {
            if (Base.Document.Cache.GetStatus(ardoc) == PXEntryStatus.Notchanged) Base.Document.Cache.SetStatus(ardoc, PXEntryStatus.Updated);
            list.Add(ardoc);
        }

      //  skipAvalaraCallOnSave = true;
        Base.Save.Press();

        PXLongOperation.StartOperation(this, delegate()
        {
            PXTimeStampScope.SetRecordComesFirst(typeof(ARInvoice), true);

            List<ARRegister> listWithTax = new List<ARRegister>();
            foreach (ARInvoice ardoc in list)
            {
                if (ardoc.IsTaxValid != true && AvalaraMaint.IsExternalTax(Base, ardoc.TaxZoneID))
                {
                    ARInvoice doc = new ARInvoice();
                    doc.DocType = ardoc.DocType;
                    doc.RefNbr = ardoc.RefNbr;
                    doc.OrigModule = ardoc.OrigModule;
                    doc.ApplyPaymentWhenTaxAvailable = ardoc.ApplyPaymentWhenTaxAvailable;
                    listWithTax.Add(ARExternalTaxCalc.Process(doc));
                }
                else
                {
                    listWithTax.Add(ardoc);
                }
            }

            SOInvoiceEntry ie = PXGraph.CreateInstance<SOInvoiceEntry>();
            SOOrderShipmentProcess docgraph = PXGraph.CreateInstance<SOOrderShipmentProcess>();
            HashSet<object> processed = new HashSet<object>();

            ARDocumentRelease.ReleaseDoc(listWithTax, adapter.MassProcess, null, delegate(ARRegister ardoc, bool isAborted)
            {
                List<object> items = new List<object>();
                items.Add(ardoc);
                PXAutomation.RemovePersisted(ie, typeof(ARInvoice), items);

                docgraph.Clear();
                foreach (PXResult<SOOrderShipment, SOOrder> ordershipment in docgraph.Items.View.SelectMultiBound(new object[] { ardoc }))
                {
                    SOOrderShipment copy = PXCache<SOOrderShipment>.CreateCopy(ordershipment);
                    SOOrder order = ordershipment;
                    copy.InvoiceReleased = true;
                    docgraph.Items.Update(copy);

                    if (order.Completed == true && order.BilledCntr <= 1 && order.ShipmentCntr <= order.BilledCntr + order.ReleasedCntr)
                    {
                        foreach (SOAdjust adj in docgraph.Adjustments.Select(order.OrderType, order.OrderNbr))
                        {
                            SOAdjust adjcopy = PXCache<SOAdjust>.CreateCopy(adj);
                            adjcopy.CuryAdjdAmt = 0m;
                            adjcopy.CuryAdjgAmt = 0m;
                            adjcopy.AdjAmt = 0m;
                            docgraph.Adjustments.Update(adjcopy);
                        }
                    }
                    processed.Add(ardoc);
                }
                docgraph.Save.Press();
            });
            PXAutomation.StorePersisted(ie, typeof(ARInvoice), new List<object>(processed));
            foreach (ARInvoice ardoc in list)
            {
                PXDatabase.Execute("pp_DMS_SO_Invoice_InsertSettleDate",
             new PXSPInParameter("@CompanyID", PXContext.GetSlot<int?>("singleCompanyID")),
             new PXSPInParameter("@InvoiceType", ardoc.DocType),
             new PXSPInParameter("@InvoiceNBR", ardoc.RefNbr));
                createARDocument(ardoc);
            }

        });

        return list;
      }  
  }

当我发布文档时,我必须手动重新加载页面。我不知道为什么它不会自动重新加载。 我调试后发现出现错误“mscorlib.dll 中发生'System.Reflection.TargetInvocationException' 类型的未处理异常”我认为它无法反映下一个操作的对象,因此它不会重新加载缓存。 感谢支持。

【问题讨论】:

    标签: cloud erp acumatica


    【解决方案1】:

    不确定您的确切问题,因为它需要进一步验证正在发生的事情。但作为一种解决方法,如果您只想从代码中重新加载屏幕,您可以抛出重定向所需的异常

    所有操作完成后,创建发票条目实例,通过搜索确切的文档设置当前,然后重定向到该图表。

    例如代码:

    PX.Objects.SO.SOInvoiceEntry invGraph = new PX.Objects.SO.SOInvoiceEntry();
    invGraph.Document.Current = invGraph .Document.Search<PX.Objects.AR.ARInvoice>(<YOUR INVOICE NUMBER>);
    throw new PXRedirectRequiredException(invGraph, "Reloading invoice");
    

    【讨论】:

      猜你喜欢
      • 2023-04-05
      • 1970-01-01
      • 2023-03-31
      • 2014-10-16
      • 1970-01-01
      • 2014-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多