Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to Update/Delete User from a Team using c# sdk

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi Friends,

I am stuck in a situation where i want to Update/Delete a User for teammembership entity. Is it possible to do that from CRM sdk. I looked for this problem and found a special request can server my purpose at least for delete operation but the catch over here is this special request "RemoveMembersTeamResponse" need MemberID and TeamId as input but in my case i have only TeamMemberShipId as input. I thought to perform retrieve operation but it throws exception saying this operation is not supported for this entity.

Is there any way to fix this issue. I am a newbie to this CRM stuff.

Thanks a lot in advance.

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to Update/Delete User from a Team using c# sdk

    Thanks a lot Aric. This workaround works for me :)

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: How to Update/Delete User from a Team using c# sdk

    You need to provide the User Id and Team Id in order to remove a member, using the Message that you specified above.

    How do you have the TeamMembershipId?

    You can use the following logic to get the Users/Teams:

               QueryExpression query = new QueryExpression()

               {

                   EntityName = teammembership.EntityLogicalName,

                   ColumnSet = new ColumnSet(true),

                   Criteria =

                   {

                       Conditions =

                       {

                           new ConditionExpression("systemuserid", ConditionOperator.Equal, userId)

                       }

                   }

               };

               EntityCollection results = service.RetrieveMultiple(query);

               foreach (Entity teammembership in results.Entities)

               {

                  Guid teamMembershipId = teammembership.Id;

                  Guid teamId = ((EntityReference)(teammembership["teamid"])).Id

                  // Call function to remove team membership record by passing User Id and Team Id

               }

    You can try using the above query with teammembershipid, but not sure if it will work.

    If it doesn't just compare the teammembershipid to the results and that way you will get the team id.

    You can also try using the disassociate method of the organization service to remove team members.

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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

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,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans