From 096c2fb080f62d591d735079e16eabfec76c9b17 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Mon, 19 Mar 2018 14:15:46 +0000 Subject: [PATCH] Use the first array index instead of hardcoding array index 1 --- webform_civicrm.module | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/webform_civicrm.module b/webform_civicrm.module index edfc5916e..221b4ace9 100644 --- a/webform_civicrm.module +++ b/webform_civicrm.module @@ -916,14 +916,13 @@ function _webform_civicrm_getCaseContactID($caseID) { civicrm_initialize(); $caseEntity = civicrm_api3('Case', 'get', array( - 'sequential' => 1, 'return' => array('contact_id'), 'id' => $caseID, )); $caseContactID = WEBFORM_CIVICRM_DEFAULT_CONTACT_ID; - if (!empty($caseEntity['values'][0]['contact_id'][1])) { - $caseContactID = $caseEntity['values'][0]['contact_id'][1]; + if ((count($caseEntity['values'][$caseID]['contact_id']) > 0) && !empty(reset($caseEntity['values'][$caseID]['contact_id']))) { + $caseContactID = reset($caseEntity['values'][$caseID]['contact_id']); } return $caseContactID;