How do I find the teams for the account currently being saved?

I have some logic that should get activated when an account is assigned to specific teams. If any of the teams associated with the account matches a team in this list, the logic should get triggered.

From the logic hook:

$teamSetBean = new TeamSet();
//Retrieve the teams from the team_set_id
$teams = $teamSetBean->getTeams($accBean->team_set_id);

In this case $teams contain the values of the teams assigned to the account *from the database*

I need the result as it's being saved right now.

When inspecting the bean, I find the results I need inside:

$accBean->teams->_teamList

But this is a private variable! I can't find any way to retrieve the data contained in the _teamList array. Even calling:

$accBean->teams->get()

just gets the data from the database.

How do I get the information for the teams currently being saved to the account?

  • So far the only work-around has been to make the _teamList variable public in /sugar/modules/Teams/TeamSetLink.php, which makes the following code do what I need it to:

    $teams = array();
    if(empty($accBean->teams->_teamList)) {
     $teamSet = new TeamSet();
     $teams = $teamSet->getTeamIds($accBean->team_set_id);
    } else {
     $teams = $accBean->teams->_teamList; // <-- this does not work without modifying the TeamSetLink.php file
    }

    Please tell me there is a better way to do this!