2016-05-13 1 views
0

私は現在のBAccount.BAccountIDで新しい受注を作成するためのアクションを追加しましたが、このエラー "値はNullではありません。誰でも私が間違ってやっていることを具体的に見ることができますか?私はcustomerIDとBAccountIDが同じIDの値を保持していたため、同等であったと仮定していました。からのPXRedirect BAccount - >新しいSOOrder、受信エラー

public PXAction<BAccount> KSSOOrderPush; 
    [PXUIField(DisplayName = "Create New Sales Order", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)] 
    [PXButton(CommitChanges = true)] 
    protected virtual void kSSOOrderPush() 
    { 
     //Must use Base.BAccount.Current INSTEAD of BAccount.Current 
     BAccount bacct = Base.BAccount.Current; 
     if (bacct == null || bacct.BAccountID == null) return; 

     //Create instance of graph 
     SO.SOOrderEntry graph = PXGraph.CreateInstance<SO.SOOrderEntry>(); 


     graph.Document.Current = graph.Document.Search<SOOrder.customerID>(bacct.BAccountID); 


     throw new PXRedirectRequiredException(graph, "Sales Order"); 


    } 

答えて

5

まず第一に、あなたは正しい - SOOrder.CustomerIDBAccount.BAccountIDと同じ値をとります。ただし、ビジネスアカウントは顧客だけでなく、ベンダー、従業員なども表していますが、顧客専用の販売注文(AR文書だけでなく)を作成することも可能ですが、これを念頭においてくださいこのアクションの際に顧客と取引していることを確認してください(BAccountクラスにタイプフィールドがあります - これで十分です)。

コードの問題は、選択した顧客の受注を実際に作成するのではなく、この顧客に属するものを見つけてそれにナビゲートすることです。あなたはこれらの変更によって

// insert an SOOrder with default type 
SOOrder newOrder = graph.Document.Insert(); 
// set appropriate CustomerID and update the order 
newOrder.CustomerID = bacct.BAccountID; 
graph.Document.Update(newOrder); 

に次の行

graph.Document.Current = graph.Document.Search<SOOrder.customerID(bacct.BAccountID); 

を変更する必要がありPXRedirectionException販売注文は、あなたがで見ていたいずれかに設定カスタマーで画面開く必要があります順序を作成するには

ビジネスアカウント画面。

+0

優れた説明、エラーを指摘していただきありがとうございます、私は推測していないでしょう。あなたが提案したソリューションは完璧に機能しました! – JB90

関連する問題