acumatica
コードによる連絡先と住所情報の変更
サーチ…
前書き
このトピックでは、Acumatica内のさまざまな画面のコードを使用して連絡先情報と住所情報を変更する方法を学習します。
新しい従業員の連絡先情報と住所情報を指定する
従業員の連絡先情報と住所情報を指定するには、フィールド値を割り当てる前に、 ContactおよびAddressデータビューで常にSelect()
メソッドを呼び出す必要があります。また、 ContactおよびAddressデータビューのCurrentプロパティにSelect()
メソッドの結果を代入して、コードがContactおよびAddress PXCacheの現在のレコードをそれぞれ変更することを保証することもお勧めします。
EmployeeMaint employeeMaintGraph = PXGraph.CreateInstance<EmployeeMaint>();
EPEmployee epEmployeeRow = new EPEmployee();
epEmployeeRow.AcctCD = "EMPLOYEE1";
epEmployeeRow = employeeMaintGraph.Employee.Insert(epEmployeeRow);
Contact contactRow = employeeMaintGraph.Contact.Current = employeeMaintGraph.Contact.Select();
contactRow.FirstName = "John";
contactRow.LastName = "Green";
employeeMaintGraph.Contact.Update(contactRow);
Address addressRow = employeeMaintGraph.Address.Current = employeeMaintGraph.Address.Select();
addressRow.CountryID = "US";
addressRow = employeeMaintGraph.Address.Update(addressRow);
addressRow.State = "DC";
employeeMaintGraph.Address.Update(addressRow);
epEmployeeRow.VendorClassID = "EMPSTAND";
epEmployeeRow.DepartmentID = "FINANCE";
employeeMaintGraph.Employee.Update(epEmployeeRow);
employeeMaintGraph.Actions.PressSave();
新しい従業員を挿入すると、連絡先レコードが自動的にキャッシュに挿入されるため、 employeeMaintGraph.Contact.Current
は常にメイン連絡先レコードを返します。したがって、PXCache /データビューのCurrentプロパティで利用できるようになります。 Select()
メソッドの使用は、新しい従業員を挿入するか、既存のEmployeeを更新する必要があるかどうかにかかわらず、すべての可能なシナリオで機能するため、少し一般的です。
顧客の請求先連絡先と請求先住所情報の上書き
顧客の請求先連絡先と請求先アドレス情報をオーバーライドする必要がある場合、最初に、 顧客 DACのIsBillContSameAsMainおよびIsBillSameAsMainプロパティの正しい値を設定します。 IsBillContSameAsMainまたはIsBillSameAsMainプロパティを更新した直後にCustomerキャッシュのUpdate()
メソッドを呼び出して、現在のSame as Mainフィールドの値をキャッシュにコミットすることを忘れないでください。
次のステップでは、フィールド値を割り当てる前に、 BillContactおよびBillAddressデータビューでSelect()
メソッドを呼び出します。また、 Select()
メソッドの結果をBillContactおよびBillAddressデータビューのCurrentプロパティに代入して、コードがContactおよびAddress PXCacheの現在のレコードをそれぞれ変更することを保証することもお勧めします。
public class CustomerMaintExt : PXGraphExtension<CustomerMaint>
{
public PXAction<Customer> UpdateBillingAddress;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Update Bill-To Info")]
protected void updateBillingAddress()
{
Customer currentCustomer = Base.BAccount.Current;
if (currentCustomer.IsBillContSameAsMain != true)
{
currentCustomer.IsBillContSameAsMain = true;
Base.BAccount.Update(currentCustomer);
}
else
{
currentCustomer.IsBillContSameAsMain = false;
Base.BAccount.Update(currentCustomer);
Contact billContact = Base.BillContact.Current = Base.BillContact.Select();
billContact.FullName = "ABC Holdings Inc";
billContact.Phone1 = "+1 (212) 532-9574";
Base.BillContact.Update(billContact);
}
if (currentCustomer.IsBillSameAsMain != true)
{
currentCustomer.IsBillSameAsMain = true;
Base.CurrentCustomer.Update(currentCustomer);
}
else
{
currentCustomer.IsBillSameAsMain = false;
Base.CurrentCustomer.Update(currentCustomer);
Address billAddress = Base.BillAddress.Current = Base.BillAddress.Select();
billAddress.AddressLine1 = "65 Broadway";
billAddress.AddressLine2 = "Office Suite 187";
billAddress.City = "New York";
billAddress.CountryID = "US";
billAddress = Base.BillAddress.Update(billAddress);
billAddress.State = "NY";
billAddress.PostalCode = "10004";
Base.BillAddress.Update(billAddress);
}
Base.Actions.PressSave();
}
}
請求書連絡先および受注の請求先住所情報を上書きする
受注の請求先住所と請求先住所情報を指定するには、フィールド値を割り当てる前に、 常にBilling_ContactおよびBilling_AddressデータビューでSelect()
メソッドを呼び出す必要があります。また、結果割り当てることが推奨されるSelect()
あなたのコードは、それぞれSOBillingContactとSOBillingAddress PXCacheに現在のレコードを変更することを保証するためにBilling_ContactとBilling_AddressデータビューCurrentプロパティにメソッドを。
あなたは連絡しSOBillingContact DACやDAC SOBillingAddress上OverrideContactとOverrideAddressプロパティの正しい値を設定して受注のための情報に対処するための法案を、上書きする必要がある場合。起動することを忘れないでくださいUpdate()
変更をコミットするOverrideContactとOverrideAddressプロパティを更新した直後にSOBillingContactとSOBillingAddressキャッシュ上のメソッドを。それが完了したら、販売注文の請求先住所と住所情報を指定することができます。
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public PXAction<SOOrder> UpdateBillingAddress;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Update Bill-To Info")]
protected void updateBillingAddress()
{
SOBillingContact contact = Base.Billing_Contact.Current = Base.Billing_Contact.Select();
if (contact.OverrideContact == true)
{
contact.OverrideContact = false;
Base.Billing_Contact.Update(contact);
}
else
{
contact.OverrideContact = true;
contact = Base.Billing_Contact.Update(contact);
if (contact == null)
{
contact = Base.Billing_Contact.Current;
}
contact.Phone1 = "+1 (908) 643-0281";
contact.Email = "[email protected]";
Base.Billing_Contact.Update(contact);
}
SOBillingAddress address = Base.Billing_Address.Current = Base.Billing_Address.Select();
if (address.OverrideAddress == true)
{
address.OverrideAddress = false;
Base.Billing_Address.Update(address);
}
else
{
address.OverrideAddress = true;
address = Base.Billing_Address.Update(address);
if (address == null)
{
address = Base.Billing_Address.Current;
}
address.AddressLine1 = "201 Lower Notch Rd";
address.AddressLine2 = "Office Suite 1936";
address.City = "Little Falls";
address.CountryID = "US";
address = Base.Billing_Address.Update(address);
address.State = "NJ";
address.PostalCode = "07425";
Base.Billing_Address.Update(address);
}
Base.Actions.PressSave();
}
}