cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JayashreeKrish
Resolver II
Resolver II

Populate User Name belonging to a particular Owner Team as dropdown in Model Driven Application

The Requirement is : It is a model driven application. We need to have a dropdown. It should have all the users name who are in a particular owner team. It should dynamically change when a new user is added/removed from Owner Team.
Work in Progress: Am able to populate systemuserids of those belonging to a particular Owner Team.
JayashreeKrish_0-1627275603578.jpeg

Doubt : I am not able to populate the User Name , Can someone please help ?

Or Is there any other API to get the list of users belonging to a particular owner team ?

JS Used: 

var req = new XMLHttpRequest();
var url = "https://org293f361d.crm.dynamics.com/api/data/v9.0/teammemberships?$select=teamid,systemuserid&$filt... eq 6830b56f-95e4-eb11-bacb-000d3a115bb2";  //id of my owner team
req.open("GET", url, 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.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var result = JSON.parse(this.response);

var formContext = executionContext.getFormContext();
for (var j = 0; j< result.value.length ; j++)
{
formContext.getControl("ddi_investigatordetails").addOption({"value" : j+1000, "text" : result.value[j].systemuserid }); //it is the choice name where i have to add user names as dropdown
}
alert("Value set");
}
}
}
req.send();

 

Ouput Json :

JayashreeKrish_0-1627276049919.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
JayashreeKrish
Resolver II
Resolver II

var entity = "team"
var select = "?$select=name";
var filter = "&$filter=name eq 'TeamName' &$expand=teammembership_association($select=fullname,domainname)";
Xrm.WebApi.retrieveMultipleRecords(entity, select + filter).then(
function success(result) {
for (var j = 0; j < result.entities[0].teammembership_association.length; j++) {
var n = result.entities[0].teammembership_association[j].fullname;
formContext.getControl("ddi_investigatordetails").addOption({"value" : j+1000, "text" : n});
}
},
function (error) {
console.log(error.message);
}
);

 

This worked fine

View solution in original post

1 REPLY 1
JayashreeKrish
Resolver II
Resolver II

var entity = "team"
var select = "?$select=name";
var filter = "&$filter=name eq 'TeamName' &$expand=teammembership_association($select=fullname,domainname)";
Xrm.WebApi.retrieveMultipleRecords(entity, select + filter).then(
function success(result) {
for (var j = 0; j < result.entities[0].teammembership_association.length; j++) {
var n = result.entities[0].teammembership_association[j].fullname;
formContext.getControl("ddi_investigatordetails").addOption({"value" : j+1000, "text" : n});
}
},
function (error) {
console.log(error.message);
}
);

 

This worked fine

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (2,962)