APIs & Integrations

Espe
Contributor

Create a form preventing duplicates

In hubspot I have the companies with an unique VAT property.

Now, I would to avoid in a form the possibility to create another company with the same VAT if it already exists.

 

How could I do this If I build a custom form (like Java, PHP....)?

 

Very Thanks

0 Upvotes
3 Replies 3
ChehakWadhdwa
Member | Diamond Partner
Member | Diamond Partner

Create a form preventing duplicates

hey @Espe 

You can use the company search API to check either a company with that VAT exist or not and if it exist you can do the next step accordingly by preventing user to submit the form.

 

here is the curl for that just replace the vat_value with value you want to check :

 

 

curl --request POST \
--url 'https://api.hubapi.com/crm/v3/objects/companies/search?hapikey=YOUR_HUBSPOT_API_KEY' \
--header 'content-type: application/json' \
--data '{
"filterGroups": [
{
"filters": [
{
"value": "vat_value",
"propertyName": "VAT",
"operator": "EQ"
}
]
}
],
"sorts": [
"name"
],
"properties": [
"name"
],
"limit": 100,
"after": 0
}'

 

fore reference = https://developers.hubspot.com/docs/api/crm/companies

 

 

 

 

0 Upvotes
Espe
Contributor

Create a form preventing duplicates

Hello @ChehakWadhdwa 

Thanks for your reply.

 

Where I have to add this code?

In my custom form?

0 Upvotes
ChehakWadhdwa
Member | Diamond Partner
Member | Diamond Partner

Create a form preventing duplicates

You can use ajax in jquery to hit api on the form submit and if in response you get the result greater then 0 then there is records with that vat and you will not alow user to submit form and if these are 0 then user can submit that form 

 

0 Upvotes