diff --git a/include/Webservices/ConvertLead.php b/include/Webservices/ConvertLead.php index 8ba28a40eabce0d6948e365f915fb6445f781c11..43eb0dd889bc3c1fa1af2a3f376d183e0e3fcc68 100644 --- a/include/Webservices/ConvertLead.php +++ b/include/Webservices/ConvertLead.php @@ -145,18 +145,25 @@ function vtws_convertlead($entityvalues, $user) { try { - $accountIdComponents = vtws_getIdComponents($entityIds['Accounts']); - $accountId = $accountIdComponents[1]; - - $contactIdComponents = vtws_getIdComponents($entityIds['Contacts']); - $contactId = $contactIdComponents[1]; - - if(!empty($entityIds['Potentials'])){ + $accountId = null; + if (isset($entityIds['Accounts']) && $entityIds['Accounts']) { + $accountIdComponents = vtws_getIdComponents($entityIds['Accounts']); + $accountId = $accountIdComponents[1]; + } + + $contactId = null; + if (isset($entityIds['Contacts']) && $entityIds['Contacts']) { + $contactIdComponents = vtws_getIdComponents($entityIds['Contacts']); + $contactId = $contactIdComponents[1]; + } + + $potentialId = null; + if(isset($entityIds['Potentials']) && $entityIds['Potentials']){ $potentialIdComponents = vtws_getIdComponents($entityIds['Potentials']); $potentialId = $potentialIdComponents[1]; } - if (!empty($accountId) && !empty($contactId) && !empty($potentialId)) { + if (!empty($contactId) && !empty($potentialId)) { $sql = "insert into vtiger_contpotentialrel values(?,?)"; $result = $adb->pquery($sql, array($contactId, $potentialId)); if ($result === false) { diff --git a/include/Webservices/Utils.php b/include/Webservices/Utils.php index 5d7f2867a3e03386de612bed7defabbee65218d6..ccdba38c14782f68e553ac501ad759ddb9a9d636 100644 --- a/include/Webservices/Utils.php +++ b/include/Webservices/Utils.php @@ -703,7 +703,7 @@ function vtws_getFieldfromFieldId($fieldId, $fieldObjectList){ */ function vtws_getRelatedActivities($leadId,$accountId,$contactId,$relatedId) { - if(empty($leadId) || empty($relatedId) || (empty($accountId) && empty($contactId))){ + if(empty($leadId) || empty($relatedId) || empty($contactId)){ throw new WebServiceException(WebServiceErrorCode::$LEAD_RELATED_UPDATE_FAILED, "Failed to move related Activities/Emails"); }