2017-07-26 8 views
0

SOOrderEntryグラフオブジェクトを使用してPO画面から受注を作成しようとしています。このエラーが来ている理由を私は設定していますので、私は、把握することはできませんグラフオブジェクトを使用して受注を作成するときのエラー

enter image description here

:私は別のスタックオーバーフローのケースからの技術を使用してブランチを選択するよ、と私は継続的に次のエラーを取得しますCustomerID。ここでは、コードです:

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(); 

答えて

1

これは、常にので、さらにあなたがキャッシュからではなく、従来のレコードへのオブジェクトに変更を加えるいくつかのローカル変数にPXCache InsertまたはUpdateメソッド呼び出しの結果を割り当てるための非常に輸入されますPXCacheとは何の共通点もありません。

問題は、以下の小さな変更によって解決されなければならない。それをやった

soorder = new SOOrder(); 
soorder.OrderType = SOOrderTypeConstants.SalesOrder; 
soorder = sograph.Document.Insert(soorder); 
+0

、ルスラン - おかげで非常に! :D – pmfith

+0

あなたは大歓迎です、ピーター! :-) – RuslanDev

関連する問題