簡體   English   中英

Acumatica警告消息僅影響裝運屏幕SO302000

[英]Acumatica Warning Message To Only Affect Shipment Screen SO302000

每當“ Shipment-SO302000”屏幕上的ShippedQty字段更改為值<OrigOrderQty時,我都試圖顯示警告,但是我只希望該特定屏幕/窗體的代碼處於活動狀態。

我添加了以下代碼以擴展SOShipmentEntry圖,該圖實現了我的最初目標,但是問題是,現在添加的代碼也被“銷售訂單-SO301000”屏幕/表單中的“創建裝運”操作所使用。

討論創建裝運動作

namespace PX.Objects.SO
{
  public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
{
  #region Event Handlers

  protected void SOShipLine_ShippedQty_FieldUpdated(PXCache cache,PXFieldUpdatedEventArgs e)
{


         var myrow = (SOShipLine)e.Row;
            if (myrow == null) return;


                if (myrow.ShippedQty >= myrow.OrigOrderQty)
                {

                }
            else
            {
                throw new PXSetPropertyException("The difference between the shipped-qty and the ordered-qty will be placed on a back-order", PXErrorLevel.Warning);
            }  

}


  #endregion
 }
}

雖然警告允許用戶將更改保存到“裝運屏幕/表格SO302000”上(因為將異常設置為警告而非錯誤),但是在使用“創建裝運”創建裝運時出現以下錯誤“銷售訂單-SO301000”屏幕上的“”按鈕。

警告適用於表單模式

通過操作按鈕在后台處理時,警告變為錯誤

有什么想法可以做到這一點? 據我了解,如果要對字段進行全局更改,則必須在DAC中進行更改,但是如果要更改僅影響使用圖形的屏幕/窗體,則必須在其中進行更改。圖形代碼本身。 我猜想“銷售訂單”屏幕中的“創建裝運”操作按鈕正在創建我在其中添加代碼的圖的實例,因此我想知道這里有哪些選項。

最好的祝福,

-Acumatica新手

如果您希望事件邏輯僅在從“運貨”屏幕中調用CreateShipment時執行,則可以覆蓋對CreateShipment的其他調用以動態刪除事件處理程序。

從SalesOrderEntry圖調用CreateShipment操作的事件是Action:

public PXAction<SOOrder> action;
[PXUIField(DisplayName = "Actions", MapEnableRights = PXCacheRights.Select)]
[PXButton]
protected virtual IEnumerable Action(PXAdapter adapter,
    [PXInt]
    [PXIntList(new int[] { 1, 2, 3, 4, 5 }, new string[] { "Create Shipment", "Apply Assignment Rules", "Create Invoice", "Post Invoice to IN", "Create Purchase Order" })]
    int? actionID,
    [PXDate]
    DateTime? shipDate,
    [PXSelector(typeof(INSite.siteCD))]
    string siteCD,
    [SOOperation.List]
    string operation,
    [PXString()]
    string ActionName
    )

在該方法中,它將創建一個SOShipmentEntry圖以創建貨件。 您可以覆蓋Action並從該圖實例中刪除您的處理程序:

SOShipmentEntry docgraph = PXGraph.CreateInstance<SOShipmentEntry>();

// >> Remove event handler
SOShipmentEntry_Extension docgraphExt = docgraph.GetExtension<SOShipmentEntry_Extension>();
docgraph.FieldUpdated.RemoveHandler<SOShipLine.shippedQuantity>(docgrapExt.SOShipLine_ShippedQty_FieldUpdated);
// << Remove event handler

docgraph.CreateShipment(order, SiteID, filter.ShipDate, adapter.MassProcess, operation, created);

請注意,為了從另一個圖引用SOShipLine_ShippedQty_FieldUpdated方法,必須將其公開:

public void SOShipLine_ShippedQty_FieldUpdated(PXCache cache,PXFieldUpdatedEventArgs e)

我也已經在該答案中描述了如何執行此操作: 更新自定義字段將導致無限循環


如果您希望事件邏輯僅在UI或Web服務中對其進行修改時才執行。

您可以使用PXFieldUpdatedEventArgs參數的ExternalCall布爾屬性。 僅當在UI或Web服務中修改了發件人字段時,此屬性值才為true。

用法示例:

protected void SOShipLine_ShippedQty_FieldUpdated(PXCache cache,PXFieldUpdatedEventArgs e)
{
   // If ShippedQty was updated in the UI or by a web service call
   if (e.ExternalCall)
   {
      // The logic here won't be executed when CreateShipment is invoked
   }
}

ExternalCall屬性(PXFieldUpdatedEventArgs)

獲取一個值,該值指定是在UI中還是通過Web Service API更改了當前DAC字段的新值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM