Breaking news from around the world
Get the Bing + MSN extension
Now Available in Community - MBAS 2019 Presentation Videos
Catch the most popular sessions on demand and learn how Dynamics 365, Power BI, PowerApps, Microsoft Flow, and Excel are powering major transformations around the globe. | View Gallery
2019 release wave 2 Discover the latest updates to Dynamics 365Release overview guides and videos Release Plan | Early Access Availability
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Talent TechTalks | Upcoming TechTalks
I had a hard time trying to figure out a way to retrieve members from a marketing segment in my code.
The link-entity between contact and msdyncrm_segment isn’t materialized in CRM. I even raised it here :Basic operations on segments using the Segmentation API
Finally fetch xml came to rescue. You can use below xml which can be executed by WebAPI or Organization service and it works on both static and dynamics segments.
<fetch version="1.0" output-format="xml-platform" mapping="logical" returntotalrecordcount="true" page="1" count="5000" no-lock="false">
<order attribute="fullname" descending="false"/>
<link-entity name="msdyncrm_segment" from="msdyncrm_segmentid" to="msdyncrm_segmentmemberid" alias="bb">
<condition attribute="msdyncrm_segmentid" operator="eq" uitype="msdyncrm_segment" value="bfc9d5d6-d6aa-e911-a859-000d3a3159df"/>
Now lets try to execute this first in web api.Use below format : https://orgurl/api/data/v9.1/contacts?fetchXml=<xml here>
Now lets try to execute this using organization service, note that i am using paging here because the number of records can be more than 5000:
var fetch = @"<fetch version='1.0' page='##pagenumber##' count='5000' no-lock='true'>
<order attribute='fullname' descending='false'/>
<link-entity name='msdyncrm_segment' from='msdyncrm_segmentid' to='msdyncrm_segmentmemberid' alias='bb'>
<condition attribute='msdyncrm_segmentid' operator='eq' uitype='msdyncrm_segment' value='6f5846d5-e5ae-e911-a84b-000d3a802d92'/>
var contactss = organizationService.RetrieveMultiple(new FetchExpression(fetch));
foreach(var contact in contactss.Entities)
var id = contact.ToEntityReference();
Apart from this fetch xml there is no way to retrieve members from the segment. There are some issues and limitation i faced during this operation, will try to share them in another post.
I hope this helps!
Business Applications communities