web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Remove/Retrieve all users from the access team template

(0) ShareShare
ReportReport
Posted on by 290

Dear All, 

Is there any way to remove all users from the access team template for a record, I noticed 'RemoveUserFromRecordTeamRequest' works only when we have userid and also it removes only one user, in our case we don't have user guids so wanted to remove all users from the team template is there any way to do so. 

Kind Regards, 

Ashok Jinkala

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Ashok,
    You could use the code below.

        public static void GetAccessTeamMembersAndRemove(IOrganizationService service)
        {
            string strFetchXML = @"<fetch>
                                 <entity name='salesorder' >
                                   <attribute name='name' />
                                       <link-entity name='principalobjectaccess' from='objectid' to='salesorderid' link-type='inner' alias='poa' >
                                          <attribute name='objectid' alias='objectid' />
                                          <link-entity name='team' from='teamid' to='principalid' link-type='inner' >
                                            <link-entity name='teamtemplate' from='teamtemplateid' to='teamtemplateid' >
                                              <attribute name='teamtemplatename' />
                                            </link-entity>
                                            <link-entity name='teammembership' from='teamid' to='teamid' link-type='inner' intersect='true' >
                                              <link-entity name='systemuser' from='systemuserid' to='systemuserid' link-type='inner' alias='user'>
                                                <attribute name='systemuserid' />
                                             </link-entity>
                                           </link-entity>
                                          </link-entity>  
    <filter type='and'>
                                           <condition attribute='objectid' operator='eq' value='GUID_OF_THE_RECORD' />
                                          </filter>  </link-entity> </entity> </fetch>"; EntityCollection entColAccessTeamMembers = service.RetrieveMultiple(new FetchExpression(strFetchXML)); foreach (Entity record in entColAccessTeamMembers) { RemoveUserFromRecordTeamRequest removeUser = new RemoveUserFromRecordTeamRequest() { Record = new EntityReference(record.LogicalName, record.Id), SystemUserId = (Guid)((AliasedValue)(record["user.systemuserid"])).Value;, TeamTemplateId = teamTemplateGuid }; service.Execute(removeUser); } }

    For more details, see the links below.

    mscrmtechie.blogspot.in/.../retrieve-access-team-members-using.html

    masoodakhtar.wordpress.com/.../addremove-user-tofrom-access-team-in-crm-2013-using-plugin-2/

    Hope this helps.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans