Hello Everyone,
I have created the Post-Operation create plugin and created team which is working fine. Now, I tried to assign role to team like as
QueryExpression query = new QueryExpression
{
EntityName = Role.EntityLogicalName,
ColumnSet = New ColumnSet("roleid"),
Criteria = new FilterExpression
{FilterOperator = LogicalOperator.And,
Condition =
{new ConditionExpression{AttributeName="name", Operator = ConditionOperator.Equal, Values = {SecurityRoleName}}},
{new ConditionExpression{AttributeName="businessunitid", Operator = ConditionOperator.Equal, Values = {budinessUnitId}}},
}};
EntityCollection roles = _service.RetrieveMultiple(query);
if(roles.Entities.Count > 0) { Role _role = roles.Entities[0].ToEntity<Role>(); roleId = _role.Id }
But it doesn't fetch the records
If I query from only by name, it fetches the record. After that, I try to associate the role to the team but it throws an error as
"The team belongs to a different business unit than the role."
_service.Associate( "team", teamId,
new Relationship("teamroles_association"),
new EntityReferenceCollection(){ new EntityReference("role", roleId)});
*This post is locked for comments