web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Retrieve Owning User Teams using JS

(1) ShareShare
ReportReport
Posted on by 595

Hi All,

I have An requirement that I need to hide and show buttons based on teams of Current Users.

How to retrieve User Trams Using Javascript?

Please help me to achieve this requirement...

  • Suggested answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    Hi, 

    var currentUserId = Xrm.Utility.getGlobalContext().userSettings.userId;
    Xrm.WebApi.retrieveMultipleRecords('team', "?$select=name,_businessunitid_value,teamtype&$expand=teammembership_association($filter=(systemuserid eq " currentUserId "))&$filter=(teammembership_association/any(o1:(o1/systemuserid eq " currentUserId ")))").then(
        function success(result) {
            console.log(result)
        },
        function (error) {
            console.log(error.message);
            // handle error conditions
        }
    );
    
    

    Manage Button visibility is tricky when you perform an async operation. Take a look to this greate example shared by Andrew: 

    https://butenko.pro/2018/11/13/showing-ribbon-button-based-on-the-result-of-async-operation/

    Good Luck

  • urklnme Profile Picture
    443 on at
    how to fill a subgrid with the teams for a specific account on the account detail page for that account.
     
    I can get the list of an account's teams using teammembership.  setFilterXML doesnt seem to work to fill the grid

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 77 Super User 2026 Season 2

#2
ParthPatel249 Profile Picture

ParthPatel249 56

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 44 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans