I’ve to attach task with my custom object. I’m using below code as defined in docs. But I can’t able to create it and my object name is ‘test’.
I've created Association class in PHP:
Association::create($from, $to, $type, $fromObjectType, $toObjectType);
$from => task_id
$to => custom_object_id
$type => I've custom object name test so I passed test_to_task
I don't have idea about $fromObjectType, $toObjectType.
Where create method contains below code:
public function create($from, $to, $type, $fromObjectType, $toObjectType)
{
$fromId = new PublicObjectId([
'id' => $from,
]);
$toId = new PublicObjectId([
'id' => $to,
]);
$publicAssociation1 = new PublicAssociation([
'from' => $fromId,
'to' => $toId,
'type' => $type,
]);
$batchInputPublicAssociation = new BatchInputPublicAssociation([
'inputs' => [$publicAssociation1],
]);
return $hubSpot->crm()->associations()->batchApi()->create($fromObjectType, $toObjectType, $batchInputPublicAssociation);
}
Where $hubSpot is:
Factory::createWithAccessToken('access_token');