-->

How to automatically refresh the SO Order Entry Pa

2019-09-08 12:16发布

问题:

I have an SO Order Entry customization that sets an Acknowledged checkbox true for each SO line during the Action Email Sales Order/quote. public CRActivityList Activity; public PXAction notification; [PXUIField(DisplayName = "Notifications", Visible = false)] [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)] protected virtual IEnumerable Notification(PXAdapter adapter, [PXString] string notificationCD ) { foreach (SOOrder order in adapter.Get()) {

      var parameters = new Dictionary<string, string>();
      parameters["SOOrder.OrderType"] = order.OrderType;
      parameters["SOOrder.OrderNbr"] = order.OrderNbr;
     Activity.SendNotification(ARNotificationSource.Customer,     notificationCD, order.BranchID, parameters);

      foreach (SOLine line in PXSelect<SOLine, Where<SOLine.orderNbr,    Equal<Required<SOLine.orderNbr>>>>.Select(Base, order.OrderNbr))
      {

           SOLineExt rowExt = line.GetExtension<SOLineExt>();
           rowExt.UsrAcknowledged = true;

               Base.Transactions.Update(line);
                //Base.Transactions.View.RequestRefresh();
               // SOOrderEntry grp = PXGraph.CreateInstance<SOOrderEntry>();
               // grp.Document.Search<SOOrder.orderNbr>(order.OrderNbr,  order.OrderType);

      }
      yield return order;
    }
  }

Everything works as expected but I have to manually refresh the page to see that the check boxes are checked. Manually refreshing the grid does not display all checks correctly. How can I automatically refresh the page after the process so that it displays correctly?

回答1:

usually a cache clear works for me but I do not see that you are persisting your change. So a user could cancel your change without saving. If you want to make sure your flag is set and saved for the user you should save the changes and then you can use the cache clear. (however save could refresh the page too)

Base.Actions.PressSave();
Base.Transactions.Cache.Clear();
Base.Transactions.Cache.ClearQueryCache();

Try that before the return.



回答2:

Try calling in the very end of action delegate:

Base.Transactions.View.RequestRefresh();

When post back is received, PXGrid only synchronize current record, not repainting/refreshing other rows.



回答3:

The code snippet below sets an Acknowledged checkbox true for each SO line during the action Email Sales Order/Quote. Unfortunately the Details grid did not automatically refresh due to an issue with ReportProcessor.ProcessReport(Report definition) method corrupting PXLongOperationState and UI thread BLC state. The issue is currently resolved in the latest 6.00.1686 build.

using PX.Data;
using PX.Objects.AR;
using System.Collections;
using System.Collections.Generic;

namespace PX.Objects.SO
{
    public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
    {
        [PXUIField(DisplayName = "Notifications", Visible = false)]
        [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
        protected IEnumerable Notification(PXAdapter adapter, [PXString] string notificationCD)
        {
            foreach (SOOrder order in adapter.Get())
            {
                var parameters = new Dictionary<string, string>();
                parameters["SOOrder.OrderType"] = order.OrderType;
                parameters["SOOrder.OrderNbr"] = order.OrderNbr;
                Base.Activity.SendNotification(ARNotificationSource.Customer, notificationCD, order.BranchID, parameters);

                foreach (SOLine line in Base.Transactions.Select())
                {
                    SOLineExt rowExt = line.GetExtension<SOLineExt>();


             rowExt.UsrAcknowledged = true;
                Base.Transactions.Update(line);
            }
            Base.Save.Press();

            yield return order;
        }
    }
}

}



标签: acumatica