Hello,
Here is the C# code to add the user from the access team.
// Add Account User to Access Team
AddUserToRecordTeamRequest teamAddRequest = new AddUserToRecordTeamRequest();
teamAddRequest.Record = erfRecord;
teamAddRequest.SystemUserId = guidSystemUserId;
teamAddRequest.TeamTemplateId = guidTeamTeplateId;
AddUserToRecordTeamResponse response = (AddUserToRecordTeamResponse)service.Execute(teamAddRequest);
TeamTeamplateId -- Access Team Template Guid
Here is the code to get the template guid from template name.
Guid guidTeamTeplateId = new Guid();
// Query using ConditionExpression and FilterExpression
ConditionExpression condition = new ConditionExpression();
//attribute name add to condition
condition.AttributeName = "teamtemplatename";
//operator add to condition
condition.Operator = ConditionOperator.Equal;
//values added to condition
condition.Values.Add(strTemplateName);
// filter creation
FilterExpression filter = new FilterExpression();
//condition added
filter.Conditions.Add(condition);
//create query expression
QueryExpression query = new QueryExpression("teamtemplate");
//filter added to query
query.Criteria.AddFilter(filter);
//retrieve all columns
query.ColumnSet = new ColumnSet("teamtemplatename");
// execute query which will retrieve the Access team teamplate
EntityCollection accessTeamColl = objService.RetrieveMultiple(query);
if (accessTeamColl != null && accessTeamColl.Entities.Count > 0)
{
guidTeamTeplateId = accessTeamColl.Entities[0].Id;
}
return guidTeamTeplateId;
}
Happy CRM'ing
Gopinath
Here is the C# code to add the user from the access team.
// Add Account User to Access Team
AddUserToRecordTeamRequest teamAddRequest = new AddUserToRecordTeamRequest();
teamAddRequest.Record = erfRecord;
teamAddRequest.SystemUserId = guidSystemUserId;
teamAddRequest.TeamTemplateId = guidTeamTeplateId;
AddUserToRecordTeamResponse response = (AddUserToRecordTeamResponse)service.Execute(teamAddRequest);
Record -- Entity Reference object of the record
SystemUserId -- User which you want to removeTeamTeamplateId -- Access Team Template Guid
Here is the code to get the template guid from template name.
public Guid GetTemplateIDByName(IOrganizationService objService, string strTemplateName)
{Guid guidTeamTeplateId = new Guid();
// Query using ConditionExpression and FilterExpression
ConditionExpression condition = new ConditionExpression();
//attribute name add to condition
condition.AttributeName = "teamtemplatename";
//operator add to condition
condition.Operator = ConditionOperator.Equal;
//values added to condition
condition.Values.Add(strTemplateName);
// filter creation
FilterExpression filter = new FilterExpression();
//condition added
filter.Conditions.Add(condition);
//create query expression
QueryExpression query = new QueryExpression("teamtemplate");
//filter added to query
query.Criteria.AddFilter(filter);
//retrieve all columns
query.ColumnSet = new ColumnSet("teamtemplatename");
// execute query which will retrieve the Access team teamplate
EntityCollection accessTeamColl = objService.RetrieveMultiple(query);
if (accessTeamColl != null && accessTeamColl.Entities.Count > 0)
{
guidTeamTeplateId = accessTeamColl.Entities[0].Id;
}
return guidTeamTeplateId;
}
Remove user from Access Team in CRM 2013 and 2015
--Happy CRM'ing
Gopinath
No comments:
Post a Comment