How to get logged-in users all teams via query.

Hello,

I am using sugar cloud,

I want to get current user's all teams using query.

Those all teams comes under user's->access tab-> My Teams.

Please assist me for the same.

Best Regards

Shiv

Parents
  • Hi Shivashankar,

    You can load the user bean and get all the related teams of user. Refer this link for more information on how to fetch related records.

    //Load the user bean 
    //replace {id} with actual user id
    $userBean = BeanFactory::getBean('Users', {id});
    
    //Load relationship of teams
    $userBean->load_relationship('teams');
    
    //$relatedTeams conatins an array of beans of all the teams of the user
    $relatedTeams = $userBean->teams->getBeans();

    Thank you,
    Vamshi S

    Bhea Technologies Pte Ltd

    https://bhea.com

Reply
  • Hi Shivashankar,

    You can load the user bean and get all the related teams of user. Refer this link for more information on how to fetch related records.

    //Load the user bean 
    //replace {id} with actual user id
    $userBean = BeanFactory::getBean('Users', {id});
    
    //Load relationship of teams
    $userBean->load_relationship('teams');
    
    //$relatedTeams conatins an array of beans of all the teams of the user
    $relatedTeams = $userBean->teams->getBeans();

    Thank you,
    Vamshi S

    Bhea Technologies Pte Ltd

    https://bhea.com

Children