More often we will need to create a Team when a new record is created in MS CRM and assign the team back to same record. This can be easily done through two plugins:
- Plugin 1: Create a Team
- Plugin 2: Assign the Team to Record
To resolve this issue we need to delay and check the application until the privilege has been assigned.
Here are steps for achieving this through single plugin:
1. Create Team based on the newly created record.
2. Assign Security role to the created Team.
3. Check if the required privilege is assigned to team and delay the application until
the privilege is set (see below).
bool teamLacksPrivilege = true;
RetrieveTeamPrivilegesRequest retrieveTeamPrivilegesRequest =
TeamId = _teamId
RetrieveTeamPrivilegesResponse retrieveTeamPrivilegesResponse =
foreach (RolePrivilege rp in
if (rp.PrivilegeId == readAccountPrivilege.Id)
teamLacksPrivilege = false;
4. Assign the Team to created Record.