PHP-SDK Delete Records Example
Greetings,
I am using the API 2.0 with the PHP-SDK.
I have figured out how to Upsert & Update Records thansk to the help of other members of the forum and zoho support. Now I am trying to figure out how to mass delete records. Bascially cleanup my mistakes :)
I see a deleteRecords function but I can't figure out how to pass an array or entity ID's to this function. If anyone else has any help or can point me in the right direction.
Thanks,
Josh
My Code, I am just pasting the pertinent parts, please excuse all the extra fluff i have for debugging.
- $entityID = $row['ZohoID'];
- echo "Row: ".$count." || ContactID: " . $entityID . " || Contact: ".$row['FirstName'] . " " .$row['LastName'];
- $records = ZCRMRecord::getInstance("Contacts",$entityID);
- //*Add to Array
- $recordsArray[]=$records;
- if ($count == 1 || $totalCount == $numRows){
- echo "<hr><hr>",EOL;
- //Reset Count
- $count =0;
- //Upload Full Records Array
- $zcrmModuleIns = ZCRMModule::getInstance("Contacts");
- $bulkAPIResponse=$zcrmModuleIns->deleteRecords($recordsArray);
-
- $entityResponses = $bulkAPIResponse->getEntityResponses();
- foreach($entityResponses as $entityResponse)
- {
- if("success"==$entityResponse->getStatus())
- {
- echo "Status:".$entityResponse->getStatus();
- echo "Message:".$entityResponse->getMessage();
- echo "Code:".$entityResponse->getCode();
- //$updateData=$entityResponse->getUpsertDetails();
- //echo "UPDATE_ACTION:".$updateData["action"];
- //echo "UPDATE_DUPLICATE_FIELD:".$updateData["duplicate_field"];
- //$createdRecordInstance=$entityResponse->getData();
- //echo "EntityID:".$createdRecordInstance->getEntityId();
- //echo "moduleAPIName:".$createdRecordInstance->getModuleAPIName();
-
- //Insert ID back into Solaria
- $deleteQUERY = " DELETE FROM CRMContactID
- WHERE ZohoID = ".ZCRMRecord::getInstance("Contacts",$entityID)." ";
- //execute query
- $DeleteResult = $mspdo->query($deleteQUERY);
-
- echo "<hr><hr>",EOL;
- }
- else
- {
- echo "<b>Error</b>",EOL;
- echo "<b>Status:</b>".$entityResponse->getStatus(), EOL;
- echo "<b>Message:</b>".$entityResponse->getMessage(), EOL;
- echo "<b>Code:</b>".$entityResponse->getCode(), EOL;
- echo "<hr><hr>",EOL;
- }
-
- }
- break;