By using this website, you agree to our Terms of Use (click here)
I'm trying to force my users to update contact information for customers including email, etc... However, when we enter sales orders, and select a customer there is no way to select a contact for the customer to auto populate the attention and email fields. I can manually type a name and email address to have this show up on the print out and have this email automatically show up on the SEND function. Does anyone know how to have these fields populate with the contact data we are already adding?
We needed something similar and ended up customizing a solution. You could have a drop of the contacts for the customer and then create an event that updates the contact info when something is selected. It should be fairly straightforward.
Here is our code for the contact selector. You will have to add the field after you create it. And then change commit changes to true on the field after added.
[PXDBInt()]
[PXUIField(DisplayName = "Contact")]
[PXSelector(typeof(Search<Contact.contactID, Where<Contact.bAccountID, Equal<Current<SOOrder.customerID>>,
And<Contact.contactType, Equal<ContactTypesAttribute.person>>>>),
typeof(Contact.displayName),
typeof(Contact.eMail),
typeof(Contact.webSite),
typeof(Contact.fax),
typeof(Contact.phone1),
SubstituteKey = typeof(Contact.displayName))]
and then here is some code to update the billing contact info
public virtual void SOOrder_UsrDefContact_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
SOOrder row = e.Row as SOOrder;
if (row == null)
return;
SOOrderPXExt rowExt = PXCache<SOOrder>.GetExtension<SOOrderPXExt>(row);
if (rowExt.UsrDefContact != null)
{
Base.Billing_Contact.Current.OverrideContact = true;
Base.Billing_Contact.Update(Base.Billing_Contact.Current);
Contact rowContact = (Contact)PXSelect<Contact, Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(Base, rowExt.UsrDefContact);
if (rowContact != null)
{
Base.Billing_Contact.Current.Email = rowContact.EMail;
Base.Billing_Contact.Update(Base.Billing_Contact.Current);
}
}
}
