Solved

Copy UDF data from lead form to contact form automatically

  • 28 July 2021
  • 1 reply
  • 108 views

Userlevel 2
Badge

On the Lead profile screen (CR301000), I created a custom field to store a string values called UsrDepartment.  I also created the same field on the Contact profile screen (CR302000).  When the user chooses to “Create Contact” from the Lead profile, it correctly creates the contact.  However, the data in the custom field I created doesn’t automatically carry over.  How and where can I add logic to copy the value over from the lead to the contact?

icon

Best answer by sd79 29 December 2022, 06:17

View original

1 reply

Userlevel 2
Badge

You can use the following code to achieve the same. I have created 2 fields Region and Industry to carry forward from Leads screen to Contact Screen.

 

namespace PX.Objects.CR
{
    

    public class ContactMaint_Extension : PXGraphExtension<ContactMaint>
    {
        #region Event Handlers
        protected void Contact_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
        {
            var row = (Contact)e.Row;
            if (row != null)
            {
                CRContactExistingColumn TargateExt = PXCache<Contact>.GetExtension<CRContactExistingColumn>(row);

                if (row.ContactID != null)
                {

                    CRLead lead = PXSelect<CRLead, Where<CRLead.refContactID, Equal<Required<CRLead.refContactID>>>>.Select(this.Base, row.ContactID);

                    if (lead != null)
                    {
                        Contact Source = PXSelect<Contact, Where<Contact.contactID, Equal<Required<Contact.contactID>>>>.Select(this.Base, lead.ContactID);
                        CRContactExistingColumn SourceExt = PXCache<Contact>.GetExtension<CRContactExistingColumn>(Source);
                        TargateExt.Usrregion = SourceExt.Usrregion;
                        TargateExt.Usrindustry = SourceExt.Usrindustry;
                    }
                }
            }
        }
        #endregion
    }
}
 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved