Acumatica 从父帐户更新客户子帐户
页码:AR303000版本:18.203.0006 很好的一天 当父帐户更改时,我需要更新子帐户详细信息(Acumatica 从父帐户更新客户子帐户,acumatica,Acumatica,页码:AR303000版本:18.203.0006 很好的一天 当父帐户更改时,我需要更新子帐户详细信息(条款、状态和电子邮件)。问题是我不知道如何从Customer\u row persisting保存儿童客户的联系人电子邮件字段。 客户子帐户确实保存了,但联系人详细信息不保存 namespace PX.Objects.AR { public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint> {
条款、状态和电子邮件)。问题是我不知道如何从Customer\u row persisting
保存儿童客户的联系人电子邮件字段。
客户子帐户确实保存了,但联系人详细信息不保存
namespace PX.Objects.AR
{
public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
#region Event Handlers
protected void Customer_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
Customer row = (Customer)e.Row;
if (row.ParentBAccountID == null)
{
PXResultset<Customer> Children = PXSelectJoin<Customer,
LeftJoin<BAccount, On<Customer.bAccountID, Equal<BAccount.bAccountID>>>,
Where<BAccount.parentBAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, row.BAccountID);
if (Children == null) { return; }
Contact ParContact = PXSelect<Contact, Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, row.DefBillContactID);
foreach (Customer item in Children)
{
//Customer
item.TermsID = row.TermsID;
item.Status = row.Status;
cache.Update(item);
//Contact Details
Contact Cur = PXSelect<Contact, Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, item.DefBillContactID);
Cur.EMail = ParContact.EMail;
cache.Update(Cur);
}
//Do not know if this is right
cache.Persist(PXDBOperation.Normal);
}
}
#endregion
}
}
名称空间PX.Objects.AR
{
公共类CustomerMain_扩展:pxGrapherExtension
{
#区域事件处理程序
受保护的无效客户保存(PXCache缓存、PXRowPersistingEventArgs e)
{
客户行=(客户)e行;
if(row.ParentBAccountID==null)
{
PXResultset Children=PXSelectJoin.Select(Base,row.BAccountID);
如果(Children==null){return;}
Contact-ParContact=PXSelect.Select(Base,row.deffBillContactId);
foreach(子项中的客户项目)
{
//顾客
item.TermsID=row.TermsID;
项目状态=行状态;
缓存更新(项目);
//联系方式
Contact Cur=PXSelect.Select(基本、项目.deffBillContactId);
Cur.EMail=ParContact.EMail;
cache.Update(Cur);
}
//不知道这是否正确
持久化(PXDBOperation.Normal);
}
}
#端区
}
}
您可以覆盖Persist()
方法!您应该为PX.CS.Contracts.dll
dll添加一个引用
public class CustomerMaintExt : PXGraphExtension<CustomerMaint>
{
#region Overrides
public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate baseMethod)
{
using (var scope = new PXTransactionScope())
{
Customer row = this.Base.BAccount.Current;
if (row?.ParentBAccountID == null)
{
CustomerMaint businessAccount = PXGraph.CreateInstance<CustomerMaint>();
PXResultset<Customer> Children = PXSelect<Customer, Where<Customer.parentBAccountID, Equal<Required<Customer.bAccountID>>>>.Select(Base, row.BAccountID);
foreach (Customer item in Children)
{
businessAccount.Clear();
businessAccount.BAccount.Current = PXSelectorAttribute.Select<Customer.bAccountID>(this.Base.BAccount.Cache, item.BAccountID) as Customer;
item.TermsID = row.TermsID;
item.Status = row.Status;
Contact defContact = PXSelect<Contact, Where<Contact.bAccountID, Equal<Required<BAccount.bAccountID>>, And<Contact.contactID, Equal<Required<BAccount.defContactID>>>>>.Select(businessAccount, item.BAccountID, item.DefContactID);
defContact.EMail = this.Base.DefContact.Current.EMail;
businessAccount.DefContact.Update(defContact);
businessAccount.BAccount.Update(item);
businessAccount.Save.PressButton();
}
}
baseMethod();
scope.Complete();
}
}
#endregion
}
公共类CustomerMaintExt:pxGrapherExtension
{
#区域覆盖
公共委托void PersistDelegate();
[PXOverride]
公共void Persist(PersistDelegate baseMethod)
{
使用(var scope=new PXTransactionScope())
{
客户行=this.Base.BAccount.Current;
if(行?.ParentBAccountID==null)
{
CustomerMain businessAccount=PXGraph.CreateInstance();
PXResultset Children=PXSelect.Select(Base,row.BAccountID);
foreach(子项中的客户项目)
{
businessAccount.Clear();
businessAccount.BAccount.Current=PXSelectorAttribute.选择(this.Base.BAccount.Cache,item.BAccountID)作为客户;
item.TermsID=row.TermsID;
项目状态=行状态;
Contact defContact=PXSelect.Select(businessAccount,item.BAccountID,item.DefContactID);
defscontact.EMail=this.Base.defscontact.Current.EMail;
businessAccount.DefContact.Update(DefContact);
businessAccount.BAccount.Update(项目);
businessAccount.Save.PressButton();
}
}
baseMethod();
scope.Complete();
}
}
#端区
}
感谢您的回复,瓦丹。我将如何将Contact.Email添加到此代码中。谢谢你,Vardan,如果我想将“折扣和促销”行发送给孩子们,是否会采用与Contacts相同的方式?