Skip to content

Instantly share code, notes, and snippets.

@omidnasri
Last active May 26, 2019 11:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omidnasri/0d6d036b25979b2e946cd2a4737499ef to your computer and use it in GitHub Desktop.
Save omidnasri/0d6d036b25979b2e946cd2a4737499ef to your computer and use it in GitHub Desktop.
A simple solution to delete person entity by ID.
<?php
/**
* Target: DeletePersonById
*
* Authors: Omid Nasri
*
* Description: A simple solution to delete person entity by ID.
*
* Version: 1.0
*/
try
{
// Enter the field with the username and password that has the necessary permission to delete the person.
$username = 'admin';
$password = 'admin';
// Replace <url> keyword to your CRM host address.
$url = 'http(s)://<url>/services/api/IPerson.svc?wsdl';
// Create new instance of SoapClient to call DeletePersonById method.
$soapClient = new SoapClient( $url );
/**
* | AssignChildrenToParent
* | DeleteChildren
* deleteOption: | Nothing
* | DeletePersons
* | DeleteWithHistory
*/
$params = array(
'username' => $username,
'password' => $password,
'personId' => '7752d1da-5699-4226-b8a1-1ee6d20b0fbf',
'deleteOption' => 'DeleteWithHistory'
);
// Calling the DeletePersonById method.
$Result = $soapClient->DeletePersonById($params);
// Checked that the operation was successful or not.
if ($Result->DeletePersonByIdResult->Success)
{
//Converting Object to JSON type then print output vlaue.
echo json_encode($Result, JSON_UNESCAPED_UNICODE);
}
else
echo $Result->DeletePersonByIdResult->Message;
}
catch ( Exception $e )
{
// Print exception message
echo $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment