Hi,
Today we got a requirement to fetch the users who are added on the Access Team of the record and do some operation.
Here is the Fetch XML to retrieve the users that were added to access team.
I was using for Order entity. If you are using for any other entity, you need to change the entity name in the 2nd line and ID schema name in the 4th line of the Fetch Xand pass record Id in the filter condition.
public static void GetAccessTeamMembers(IOrganizationService iService)
{
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' >
<attribute name='fullname' />
</link-entity>
</link-entity>
</link-entity>
<filter type='and'>
<condition attribute='objectid' operator='eq' value='GUID_OF_THE_RECORD' />
</filter>
</link-entity>
</entity>
</fetch>";
Hope this helps.
--
Happy CRM'ing
Gopinath
Today we got a requirement to fetch the users who are added on the Access Team of the record and do some operation.
Here is the Fetch XML to retrieve the users that were added to access team.
I was using for Order entity. If you are using for any other entity, you need to change the entity name in the 2nd line and ID schema name in the 4th line of the Fetch Xand pass record Id in the filter condition.
public static void GetAccessTeamMembers(IOrganizationService iService)
{
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' >
<attribute name='fullname' />
</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 = iService.RetrieveMultiple(new FetchExpression(strFetchXML));
}Hope this helps.
--
Happy CRM'ing
Gopinath
No comments:
Post a Comment