0

I did setup a web-to-lead form for a non-profit organization. The customer is not going to use Leads in Salesforce. I did setup a record-triggered flow after the web-to-lead. Once the lead is saved into salesforce, the flow calls an apex class with an invocable method that converts the Lead into an Account and Contact. However, this is always creating a new account and contact.

If a contact or account exists in the system, the lead should not create a new account, but updates the existing account and contact with the field values from the web-to-lead form. If the email from the web-to-lead doesn't match with an existing account or contact, a new account and contact should be created.

Can someone help?

I am trying to achieve this with a declarative approach if possible as the customer doesn't have the resources to modify the web code to make a webservice callout by passing the JSON data from the form. So, this will be my last option if the web-to-lead with lead conversion doesn;t workout.

2
  • A challenge is what if there are multiple matching accounts? And does your org settings allow a contact to exist in multiple accts? Apex can set account id on convert but if its ever wrong (or cant pick between multiple) the client might want some selection screen instead - at which point you may be better off just flagging WebToLead leads so that an admin can resolve/merge with any potential dupe accounts. If you solve by apex consider shipping with on/off switch (metadata setting) and possibly other settings to make it somewhat declarative. (Btw apex can leverage declarative dupe rules.) Jan 21 at 6:24
  • Thanks for your response. I am planning to use Email as the external id field to match the account and contact. Jan 21 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.