2017-04-20 3 views
0

ビジネスアカウントDACを新しいUsrAccountTypeフィールドで拡張しました。そのフィールドがビジネスアカウント更新グラフで更新されるときには、関連する顧客レコードのさまざまなフィールドも更新する必要があります。しかし、「エラー#91:他のプロセスがBAccountレコードを更新しました。変更が失われます。」発生する。顧客をBAccountMaint拡張から更新します(エラー#91別のプロセスが更新されました..)

私は、CustomerクラスのサブセットであるAccount Typeと同じ値にCustomer.customerClassIDフィールドを設定しようとしています。&カスタマークラスの変更に関連する他のフィールドへの変更は適用する必要はありません。

public class BusinessAccountMaint_Extension : PXGraphExtension<BusinessAccountMaint> 
{ 
    public PXSelect<Customer, Where<Customer.bAccountID, Equal<Current<BAccount.bAccountID>>>> ARCustomer; 

    public virtual void BAccount_UsrAccountType_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) 
    { 
     BAccount row = (BAccount)e.Row; 
     if (row == null) return; 
     BAccount_Extension rowExt = row.GetExtension<BAccount_Extension>(); 

     Customer customer = ARCustomer.Current; 
     if (customer == null) return; 

     customer.CustomerClassID = rowExt.UsrAccountType; 
     // additional changes to Customer record 
     this.Base.Caches<Customer>().Update(customer); 
    } 
} 

BAccountと同時に顧客を更新するにはどうすればよいですか? CustomerMaintグラフを作成し、それを使ってレコードを更新する必要がありますか?両方のレコードを同時に更新しても同じ問題は発生しませんか?あるいは、BAccountの変更が永続化され、顧客への変更がそこで行われた後、BAccount_RowPersistedで何かを行うことができますか?

答えて

1

この現象の根本原因は、顧客がBAccountから派生していることです。

[PXCacheName(Messages.Customer)] 
[PXEMailSource] 
public partial class Customer : BAccount, PX.SM.IIncludable 
{ 

お客様のレコードを更新すると、BAccountレコードも更新されます。

これを回避するには、BAccountから派生していない独自のカスタマーDACを作成して更新する必要があります。

namespace SomeNamespce 
{ 
    [Serializable] 
    public partial class Customer : IBqlTable 
    { 
     public abstract class bAccountID : PX.Data.IBqlField 
     { 
     } 
     [PXDBIdentity((IsKey = true))] 
     public virtual int? BAccountID 
     { 
      get; 
      set; 
     } 
     public abstract class customerClassID : PX.Data.IBqlField 
     { 
     } 
     [PXDBString(10, IsUnicode = true)] 
     //[PXDefault(typeof(Search<ARSetup.dfltCustomerClassID>))] 
     //[PXSelector(typeof(CustomerClass.customerClassID), DescriptionField = typeof(CustomerClass.descr), CacheGlobal = true)] 
     public virtual String CustomerClassID 
     { 
      get; 
      set; 
     } 
    } 
} 
namespace YourNamespace 
{ 
    public class BusinessAccountMaint_Extension : PXGraphExtension<BusinessAccountMaint> 
    { 
     public PXSelect<SomeNamespce.Customer , Where<SomeNamespce.Customer.bAccountID, Equal<Current<BAccount.bAccountID>>>> ARCustomer; 

     public virtual void BAccount_UsrAccountType_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) 
     { 
      BAccount row = (BAccount)e.Row; 
      if (row == null) return; 
      BAccount_Extension rowExt = row.GetExtension<BAccount_Extension>(); 

      SomeNamespce.Customer customer = ARCustomer.Current; 
      if (customer == null) return; 

      customer.CustomerClassID = rowExt.UsrAccountType; 
      // additional changes to Customer record 
      ARCustomer.Update(customer); 
     } 
    } 
} 
関連する問題