To do this you need to edit soap\SoapPortalHelper.php and change the query to return the user's child accounts as well:
PHP Code:
function get_accounts_from_contact($contact_id, $orderBy = '')
{
// First, get the list of IDs.
$query = "SELECT account_id as id from accounts_contacts where contact_id='$contact_id' AND deleted=0"
." UNION "
."SELECT a2.id from accounts_contacts c "
."inner join accounts a on c.account_id = a.id "
."inner join accounts a2 on a.id = a2.parent_id "
."where c.contact_id='$contact_id' "
."AND c.deleted=0 AND a.deleted = 0 AND a2.deleted = 0 ";
if(!empty($orderBy)){
$query .= ' ORDER BY ' . $orderBy;
}
$sugar = new Contact();
set_module_in($sugar->build_related_in($query), 'Accounts');
}
This will cause a problem when creating a new case now though because it will create the new case an attach it to contact's child account instead of the contact's direct account. To work around that edit this portion to set the account_id as the first id in the list:
PHP Code:
function set_module_in($arrayList, $module_name){
if(!isset($_SESSION['viewable'][$module_name])){
$_SESSION['viewable'][$module_name] = array();
}
/** [IC] 2006/03/23 - get first id as the main account id */
$first_id = "-1";
foreach($arrayList['list'] as $id){
if($first_id == "-1") $first_id = $id;
$_SESSION['viewable'][$module_name][$id] = $id;
}
if($module_name == 'Accounts' && isset($first_id)){
$_SESSION['account_id'] = $first_id;
}
Next up is to be able to select from a dropdown which account to create a case for.
Bookmarks