[英]How to get extension of graph acumatica
嗨,我正在嘗試獲得擴展我知道如何獲得這樣的擴展
InventoryItem itemsx = (InventoryItem)Base.ItemSettings.Current;
var ItemExt = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(itemsx);
但是,如果我想獲得創建圖形擴展,我可以獲得圖形引用但無法獲得它的擴展。
SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();
var extgraph = graph.GetExtension<SOOrderEntry>();
我做得對嗎我無法在我的代碼上獲得 SOOrderEntryExt 我不知道為什么有人可以幫助我提前感謝
要訪問BLC
擴展實例,您應該在現有基礎 class 實例上調用GetExtension<T>(object)
GetExtension<T>(object)
方法,或者首先創建基礎 BLC 的新實例,然后在實例。
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public PXAction<SOOrder> UpdateDoc;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Recalculate Price")]
public virtual IEnumerable updateDoc(PXAdapter adapter)
{
if (this.Base.Document.Current != null)
{
InventoryItemMaint itemMaint = PXGraph.CreateInstance<InventoryItemMaint>();
/*you can access an instance of a BLC extension through the base BLC
* object by using the GetExtension< T > (object)generic method of the PXGraph class*/
var itemMaintExt = itemMaint.GetExtension<InventoryItemMaintExt>();
foreach (SOLine line in this.Base.Transactions.Select())
{
InventoryItem inventory = PXSelectorAttribute.Select<SOLine.inventoryID>(this.Base.Transactions.Cache, line, line.InventoryID) as InventoryItem;
if (inventory != null)
{
InventoryItem inventoryNew = itemMaintExt.UpdatePrice(itemMaint, inventory);
line.CuryUnitPrice = inventoryNew.BasePrice;
this.Base.Transactions.Update(this.Base.Transactions.Current);
}
}
this.Base.Save.PressButton();
}
return adapter.Get();
}
}
public class InventoryItemMaintExt : PXGraphExtension<InventoryItemMaint>
{
public virtual InventoryItem UpdatePrice(InventoryItemMaint itemMaint,InventoryItem item)
{
if (item != null)
{
itemMaint.Item.Current = item;
item.BasePrice = 500M;
itemMaint.Item.Update(item);
itemMaint.Save.PressButton();
}
return item;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.