2016-09-30 55 views
0

我想在發貨屏幕(SO302000)上的'確認貨件'操作時執行一些代碼(更改發貨日期)。確認發貨時執行代碼

我在想,這將是做到這一點的方式:

public class SOShipmentEntryExt : PXGraphExtension<SOShipmentEntry> 
{ 
    [PXOverride] 
    public virtual void ConfirmShipment(SOOrderEntry docgraph, SOShipment shiporder) 
    { 
     Base.ConfirmShipment(docgraph, shiporder); 
     //Add my code to do something here... 
    } 

} 

當我嘗試,我得到一個裝運計數器錯誤。有一個更好的方法嗎?

+0

你可以在這裏找到一個非常類似的情況:http://stackoverflow.com/questions/39211401/how-to-add-custom-business-logic- to-acumatica-frameworks-actions/39211402#39211402 –

+0

啊 - 美麗,謝謝..所以,我想這並不真正'取代'原來的Actions按鈕,因爲所有其他選項仍然存在,即使Action code在圖形擴展中只有一個選項 - 確認發貨 - 在它...不知道它是如何工作的 - 但它的工作原理。 – pmfith

+0

那麼你可以覆蓋ConfirmShipment方法,但你也必須複製粘貼所有的原始代碼,以免破壞函數。如果你真正需要的是在調用原始方法之前進行一些預處理,我認爲我給出的鏈接的解決方案更簡單,更清潔 –

回答

1

從一個類似的案件: How to add custom business logic to Acumatica framework's Actions?

public class SOShipmentEntryExt : PXGraphExtension<SOShipmentEntry> 
{ 

    public PXAction<SOShipment> action; 
    [PXButton] 
    [PXUIField(DisplayName = "Actions", MapEnableRights = PXCacheRights.Select)] 
    protected IEnumerable Action(PXAdapter adapter 
           ,[PXIntList(new int[] { 1 } 
           ,new string[] { "Confirm Shipment" }) 
           ,PXInt] int? actionID) 
    { 
     //actionID = 1 means the Confirm Shipment action was the one invoked 
     if (actionID == 1) 
     { 

      Base.Document.Current.ShipDate = Base.Accessinfo.BusinessDate; 
      Base.Document.Update(Base.Document.Current); 
     } 

     //calls the basic action that was invoked 
     return Base.action.Press(adapter); 
    } 

}