APIs & Integrations

darrengates
Member

Check for existing email on form submit

I'm looking for a way to get an an error message on the form that indicates that a user has already submitted the form before. E.g. by checking for an existing email address from a previous form submission. Does anything like this exist in hubspot? I.e., after clicking submit, rather than always getting the response message, the user might see an error to the effect that the email address already exists in the system (email is a required field in my form).

3 Replies 3
WendyGoh
HubSpot Employee
HubSpot Employee

Check for existing email on form submit

Hey @darrengates,

 

I believe my colleague Isaac responded to a similar query on this forum thread.

 

Do check it out and I hope this helps!

0 Upvotes
darrengates
Member

Check for existing email on form submit

Thanks for the reply. The Forms API appears to be what I need, however I'm trying to implement this on the front-end of a hubspot page. I.e., I would like to make an Ajax request to the Forms API, passing in the email address that was entered, and then getting back a JSON response indicating whether the email exists.

 

The problem that I am currently facing is that CORS restrictions in the API do not permit client-side requests. As I do not have an external web server other than Hubspot to use, I was hoping to leverage HubL instead. Is there a way that I can hit a page, and have HubL look up the email using the Forms API, with the secret API key a HubL variable (so that it remains server-side)?

 

Or, is there some other way that I can get around the CORS restriction on front-end API requests in this case?

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Check for existing email on form submit

Hey @darrengates,

 

If that's the case, your team might want to explore the option of using a serverless function: Serverless Functions Overview

 

In which you can write server side code that interacts with HubSpot and third party services through APIs.

0 Upvotes