Skip to main content

Notifications

Announcements

No record found.

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

  • Verified answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: get security roles of team using webApi in javascript .

    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans