0
我試圖使用SOOrderEntry圖形對象從PO屏幕創建銷售訂單。我選擇使用從另一個堆棧溢出的情況下的技術分支,和我不斷收到以下錯誤:使用圖形對象創建銷售訂單時出錯
我想不通爲什麼這個錯誤就要到了,因爲我設置客戶ID。下面的代碼:
public class POOrderEntryExt : PXGraphExtension<POOrderEntry>
{
public override void Initialize()
{
Base.action.AddMenuAction(CreateSO);
}
public PXAction<POOrder> CreateSO;
[PXUIField(DisplayName = "Create Sales Order", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton]
protected virtual void createSO()
{
SOOrderEntry sograph = null;
SOOrder soorder = null;
SOLine soline = null;
//Let's get the current data from the screen we're in...
var poorder = (POOrder)Base.Document.Current;
PXResultset<POLine> res = PXSelect<POLine, Where<POLine.orderNbr, Equal<Required<POLine.orderNbr>>>>.Select(Base, poorder.OrderNbr);
using (PXLoginScope ls = new PXLoginScope("admin"))
{
//Create a new instance of the AP Bills screen graph..
sograph = PXGraph.CreateInstance<SOOrderEntry>();
//Get the branch...
var branch = (Branch)PXSelect<Branch, Where<Branch.branchCD, Equal<Required<Branch.branchCD>>>>.Select(Base, "WI-NVC VET");
//soorder.BranchID = branch.BranchID;
//This handler is added per RD from another Stack Overflow case. It's necessary to select the Branch...
sograph.FieldDefaulting.AddHandler<SOOrder.branchID>((s, e) =>
{
e.NewValue = branch.BranchID;
e.Cancel = true;
});
soorder = new SOOrder();
//The OrderType...
soorder.OrderType = SOOrderTypeConstants.SalesOrder;
sograph.Document.Insert(soorder);
soorder.OrderDate = (DateTime?)DateTime.Now;
soorder.RequestDate = (DateTime?)DateTime.Now;
//Get the customer id...
var bacct = (BAccountR)PXSelect<BAccountR, Where<BAccountR.acctCD, Equal<Required<BAccountR.acctCD>>>>.Select(Base, "NE-C003118");
soorder.CustomerID = bacct.BAccountID; // (int?)5454;
sograph.Document.Update(soorder);
sograph.Actions.PressSave();
也做到了,魯斯蘭:
的問題應該由以下的微小變化來解決! :D – pmfith
非常歡迎你,彼得! :-) – RuslanDev