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 CRM (Archived)

get security roles of team using webApi in javascript .

(0) ShareShare
ReportReport
Posted on by 382

Hi All ,

I am trying to get Security roles of team using webApi . i can get result.length as 1  but am getting lenght as zero ."result[0].teamroles_association.length" . i have one security role for team.

below is the code .

query = '$expand=teamroles_association($select=name)&$filter=teamid eq ' + ownerId ;

WebApi.SDK.retrieveMultipleRecords('teams', query,
function (result) {
if (result.length > 0) {
for (var a = 0; a < result[0].teamroles_association.length; a++) {
var teamroles_association_name = result.teamroles_association[a]["name"];
}
}
},
function (error) {
alert(error.message);
NmErrorLogger.log(error, 'Library_CommonFunction.js: isPartOfOpportunitySplitPilot');
// Error Handler
},
function () {
},
false, null
);

Please Suggest .

Thanks ,

Waseem.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Can you please try with this -

    var teamid = "Mentioned the GUID of Team";
    
    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.0/teams(" + teamid + ")?$expand=teamroles_association($select=name)", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function () {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 200) {
                var result = JSON.parse(this.response);
                for (var a = 0; a < result.teamroles_association.length; a++) {
                    var teamroles_association_name = result.teamroles_association[a]["name"];
                }
            }
            else {
                alert(this.statusText);
            }
        }
    };
    req.send();


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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans