We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
May 26, 2021 1:53 AM
Hi Team,
I need to create a lookup for my custom object's field to the contacts the email field.
As I need to have a form for custom object data entered by the user, so I have an email field in a custom object, where once the new record is created in a custom object, the contacts with the same email should have a lookup to custom object's record.
Thank you
Solved! Go to Solution.
May 27, 2021 5:04 AM
Hi @MShekar ,
Please tried below code. Search email from custom object row from existing email :
<?php
$url = "https://api.hubapi.com/crm/v3/objects/<objectID>/search?hapikey=demo";
$data = '{
"filterGroups":[
{
"filters":[
{
"propertyName": "email",
"operator": "EQ",
"value": "test@gmail.com"
}
]
}
]
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$result = json_decode($result);
if(isset($result->total)){
if($result->total > 0) {
$record_id = $result->results[0]->id;
return 'true';
} else {
return 'false';
}
}
Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.
May 27, 2021 5:04 AM
Hi @MShekar ,
Please tried below code. Search email from custom object row from existing email :
<?php
$url = "https://api.hubapi.com/crm/v3/objects/<objectID>/search?hapikey=demo";
$data = '{
"filterGroups":[
{
"filters":[
{
"propertyName": "email",
"operator": "EQ",
"value": "test@gmail.com"
}
]
}
]
}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$result = json_decode($result);
if(isset($result->total)){
if($result->total > 0) {
$record_id = $result->results[0]->id;
return 'true';
} else {
return 'false';
}
}
Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.
May 26, 2021 11:39 AM
@lynton , any advice here?
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |