web
You’re offline. This is a read only version of the page.
close
Skip to main content
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...

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at
    RE: Retrieve Owning User Teams using JS

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
#ManoVerse Profile Picture

#ManoVerse 101

#2
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 66 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans