Hello,
I'm facing a problem to add members in team, the structure of my collection doesn't pass, any help please? here is my code generated by CRM BUILDER
var parameters = {}; parameters.Members = "Collection(mscrm.systemuser) Not Handled"; var req = new XMLHttpRequest(); req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/teams(740D4C8E-9FFC-E632-84FA-5055F49AEA41)/Microsoft.Dynamics.CRM.AddMembersTeam", false); 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 === 204) { //Success - No Return Data - Do Something } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(JSON.stringify(parameters));
Thank you
*This post is locked for comments
Hi,
Thank you for the response, i'm getting Can't add members to the default business unit team. The query doesn't work with default teams? Thanks
No issues, Staring at GUIDS long enough and they all blend together. Happy it was a simple thing.
Matt,
Thanks. That was a stupid mistake. Now it works fine.
So looking at your example:
POST [Organization URI]/api/data/v8.2/teams(2AF3F0D3-A30F-E711-810A-3863BB34FB48)/Microsoft.Dynamics.CRM.AddMembersTeam HTTP/1.1
The ID of the team is : 2AF3F0D3-A30F-E711-810A-3863BB34FB48
In your data your passing in, your passing in the SAME ID for the system user: Members: [{"ownerid": "2af3f0d3-a30f-e711-810a-3863bb34fb48"}]
In this case, your trying to tell it to add a itself(the team) to the team, thus a circular ref. thus the SQL error.
if you use a system user vs a the team itself, it will work.
Matt,
I tried that approach and I keep getting "Generic SQL Error". Here is my request:
POST [Organization URI]/api/data/v8.2/teams(2AF3F0D3-A30F-E711-810A-3863BB34FB48)/Microsoft.Dynamics.CRM.AddMembersTeam HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
{
Members: [{"ownerid": "2af3f0d3-a30f-e711-810a-3863bb34fb48"}]
}
The syntax your going for is this:
where the TeamID = 37C0E3C9-7A0F-E711-810E-C4346BB59828
where the userID being added is = f8585131-320f-4503-91e9-46a3791baae4
The URI would look like this :
(rootURL)/api/data/v8.2/teams(37C0E3C9-7A0F-E711-810E-C4346BB59828)/Microsoft.Dynamics.CRM.AddMembersTeam
The body would contain
{
"Members": [{ "ownerid":"f8585131-320f-4503-91e9-46a3791baae4"}]
}
When executed and successful you will get a 204 No content back on success.
if you needed more then one user, you would add ownerid: ID array elements to it.
Hope that helps.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156