Greetings, Saeros.
Saeros - Mar 14, 2010 05:19pm
Ok, I can import a contact, I can import a company, my form submits both, but how do I link the contact to the company from within the web form?
You can find the answer in the contacts api documentation:
to link the item to one or more contacts, companies or project blogs use <relateditems><add><relatedto><id>{relatedtoid}</id></relatedto>...</add></relateditems>
So, if you use our example, please add related companies as in the following example:
//
// Adding the contact
//
$contactData = array(
‘firstname’ => $requestData[‘firstname’],
‘lastname’ => $requestData[‘lastname’],
‘jobtitle’ => $requestData[‘jobtitle’],
‘businessemail’ => $requestData[‘businessemail’],
// Related companies
‘relateditems’ => array(
‘add’ => array(‘relatedto’ => array({companyId}))
),
);
Where {companyId} is the ID of the company you want to link your new contact with.
If you don’t use our example, just prepare the xml (json, form encoded data if you use one of these) according to the documentation e.g
<request>
<firstname>Aaron</firstname>
<lastname>Baileys</lastname>
<relateditems>
<add>
<relatedto>315890</relatedto>
</add>
</relateditems>
...
</request>
Saeros - Mar 14, 2010 05:19pm
Also, A loop to check for an existing contact ID would be nice. So that it would update a contact from the submission rather than creating a new duplicate.
You can use GET https://secure.solve360.com/contacts which returns a collection of contacts that match the requested criteria, please check the docs and the ‘examples’ section.
If you use our php library the code should be something like:
$searchOptions = array(
‘limit’ => 10000000,
‘filtermode’ => ‘’,
‘filtervalue’ => ‘’,
‘searchmode’ => ‘Cany’,
‘searchvalue’ => ‘John Smith’,
);
$contacts = $solve360Service->searchContacts($searchOptions);
if (count($contacts)) { // some contacts are found
$contact = array_shift($contacts); // get the first one
$id = (integer) $contact->id; // and here is the id that you can use
}