Mscrm 2011 plugin: direct fetch xml synatx used for retrieve
public List<Guid> GetRelatedPracticeGroupIds(IOrganizationService service, Guid accountId)
{
List<Guid> PracticeGroupIds = new List<Guid>();
string fetchXml = @"<fetch version=""1.0"" output-format=""xml-platform"" mapping=""logical"" distinct=""true"">
<entity name=""lrl_practicegroup"">
<attribute name=""lrl_practicegroupid"" />
<order attribute=""lrl_name"" descending=""false"" />
<link-entity name=""lrl_lrl_practicegroup_account"" from=""lrl_practicegroupid"" to=""lrl_practicegroupid"" visible=""false"" intersect=""true"">
<link-entity name=""account"" from=""accountid"" to=""accountid"" alias=""ac"">
<filter type=""and"">
<condition attribute=""accountid"" operator=""eq"" uitype=""account"" value=""" + accountId + @""" />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>";
EntityCollection Result = service.RetrieveMultiple(new FetchExpression(fetchXml));
if (Result.Entities.Count > 0)
{
foreach (Entity node in Result.Entities)
{
PracticeGroupIds.Add(node.Id);
}
}
return PracticeGroupIds;
}
}
No comments:
Post a Comment