Skip to main content

Notifications

Announcements

No record found.

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,087 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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,784 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans