function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Christian CallisonChristian Callison 

Flow to query custom object email field from Lead/Contact object

Hi Everyone,
 
I am working on a requirement to check the Lead/Contact email address, against the email address on a separate custom object named "Do not call Log'. For example, if the email address of fake123452@fakeemail.com exists in the email field, on the "Do not call Log" object a user should not be able to create a new Lead/Contact with that same email address. The user should get an error message stating that 'Email address already exists…" I was thinking of creating a flow to run a loop over the "Do not call log" object to check if that email already exists, however, I can't determine a way to get a message to the user upon trying to save the lead/Contact record.
 
Does anyone have any suggestions or thoughts? Should this be done via Apex?
Gaurav HandooGaurav Handoo
Hi Christian

Your approach is correct, however, Salesforce won't allow showing a message on Standard page while creating/editing a record using Visual Flows. Reason for the same, being that Autolaunched flows are invoked via Process Builder and an external events post insertion of record, while the validation in question needs to run before insertion of record.

This can however be achieved if you are having lead/contact creation process through Visual Flow screens itself. Otherwise, only option is to have a trigger to stop creation of lead/contact.

Hope this helps. Please mark as best answer if it does.

Cheers!!
Gaurav