APIs & Integrations

wm-dev
Member

reading/updating contact properties with composer package

SOLVE

Hello,

 

I'm using the composet package to cummunicate with the API. I know how to create contact:

 

$contactInput = new SimplePublicObjectInput();
$contactInput->setProperties([
    'email' => $user->getEmail(),
    'firstname' => $user->getFirstName(),
    'lastname' => $user->getLastName(),
]);

/** @var SimplePublicObject $contact */
$contact = $this->hubspot->crm()->contacts()->basicApi()->create($contactInput)

 

 And how to read that contact identified by email:

 

$filter = new Filter();
$filter->setPropertyName('email')->setOperator('EQ')->setValue($email);

$filterGroup = new FilterGroup();
$filterGroup->setFilters([$filter]);

$searchRequest = new PublicObjectSearchRequest();
$searchRequest->setFilterGroups([$filterGroup]);

/* @var CollectionResponseWithTotalSimplePublicObject $contactsPage */
$contactsPage = $this->hubspot->crm()->contacts()->searchApi()->doSearch($searchRequest);

 

 

Now i want to read and update this contact with additional infos/properties. Not the default properties, I mean the extending properies.

In the hubspot backend I can see an set this, when I click on details. But in did not find a way to read all propery values of that contact, or set them.

 

With this way i only can get informations about the different property group and all the propertyfields in that propertygroups

$this->hubspot->crm()->properties()

e.g. which type or label have the fields.


I didn't figured out how to get the values of these propertygroups and and extending fields to a single contact. I need to read and set them.

 

Can someone give me a hint, what is the proper way to manage that?

 

0 Upvotes
1 Accepted solution
wm-dev
Solution
Member

reading/updating contact properties with composer package

SOLVE

I am one step further, this is the way I can get all the desired values of the properties:

 

/** @var SimplePublicObject $contact */
$contact = $this->hubspot->crm()->contacts()->basicApi()->getById(
    $userId,
    implode(',', $propertiesToDisplay)
);
$contact->getProperties();

 

 

And I found out that I can just add the property values to contact. In all examples, and when I read a contact without defining the properties, there were just the basic properties, so I thought for the ohter properties, must be an other way to read/add them.

 

$contact = new SimplePublicObjectInput();
$contact->setProperties([
    'email' => $person->getEmail(),
    'firstname' => $person->getFirstName(),
    'lastname' => $person->getLastName(),
    'special_property_one' => 'somevalue,
    'special_property_two' => 'someothervalue',
]);

 

 

Easier than expected 👍

 

 

View solution in original post

4 Replies 4
wm-dev
Solution
Member

reading/updating contact properties with composer package

SOLVE

I am one step further, this is the way I can get all the desired values of the properties:

 

/** @var SimplePublicObject $contact */
$contact = $this->hubspot->crm()->contacts()->basicApi()->getById(
    $userId,
    implode(',', $propertiesToDisplay)
);
$contact->getProperties();

 

 

And I found out that I can just add the property values to contact. In all examples, and when I read a contact without defining the properties, there were just the basic properties, so I thought for the ohter properties, must be an other way to read/add them.

 

$contact = new SimplePublicObjectInput();
$contact->setProperties([
    'email' => $person->getEmail(),
    'firstname' => $person->getFirstName(),
    'lastname' => $person->getLastName(),
    'special_property_one' => 'somevalue,
    'special_property_two' => 'someothervalue',
]);

 

 

Easier than expected 👍

 

 

quentin_lamamy
Key Advisor | Diamond Partner
Key Advisor | Diamond Partner

reading/updating contact properties with composer package

SOLVE

Hi @wm-dev ,

If i good understand you want to retrieve / update custom field ?


wm-dev
Member

reading/updating contact properties with composer package

SOLVE

Hi  @quentin_lamamy

yea, probably you are right. I dont know exactly if these are custom fields, as someone else configured them for me, but in fact they can be configured, they might be custom fields.
I mean these fields: when I'm in the hubspot backend and click in a contact on the button "view all properties", there is a list with many other proprties, beside the default ones, and they are grouped. These fields I want to retieve/update for a contact.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

reading/updating contact properties with composer package

SOLVE

Hello @wm-dev 

Tagging in @quentin_lamamy here.  He is working with this SDK extensively

0 Upvotes