web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer Insights - Journeys forum

How to retrieve members of a marketing segment

(0) ShareShare
ReportReport
Posted on by

Hi, is there an action or something like that to retrieve the members of an msdyncrm_segment? Apparently the documentation does not cover that topic: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/marketing/developer/extend-segments

We would like to use the result list of an segment in an external application.

The query language of segments does not appear familiar to me. What language is this or can it be translated into fetchxml?

Categories:
I have the same question (0)
  • Christian Abeln Profile Picture
    on at

    Hello,

    there is currently no API available that allows external consumption of segment results.

    We are looking at this topic for a future release.

    The query language in dynamics segments is not Fetch XML but a language that had been introduced with the formed version of Dynamics Customer Insights. A subset of that language is used as the composition language for segment queries.

    Please note that segment queries support filtering by interactions, which is not supported with FetchXML.

  • Suggested answer
    Community Member Profile Picture
    on at

    Even though it probably is unsupported I found a way to get what I want:

    /api/data/v9.0/contacts?fetchXml=<fetch version="1.0" output-format="xml-platform" returntotalrecordcount="true"  page="1"  count="2147483646" no-lock="false">

       <entity name="contact" >

           <attribute name="statecode" />

           <attribute name="entityimage_url" />

           <attribute name="fullname" />

           <order attribute="fullname" descending="false" />

           <attribute name="parentcustomerid" />

           <attribute name="emailaddress1" />

           <attribute name="company" />

           <attribute name="contactid" />

           <link-entity name="msdyncrm_segment" from="msdyncrm_segmentid" to="msdyncrm_segmentmemberid" alias="bb" >

               <filter type="and" >

                   <condition attribute="msdyncrm_segmentid" operator="eq" uitype="msdyncrm_segment" value="[GUID of segment]" />

               </filter>

           </link-entity>

       </entity>

    </fetch>

    There is a plugin on the contacts entity delivered by the marketing solution that fires on "RetrieveMultiple". There seems to be some ugly programming inside, which retrieves the query from the segment and transforms it into a query against the D365 data. It also handles paging, which probably is implemented for the subgrid view inside the members section of the segment form. 2147483646 is the max amount of records you can retrieve for 1 page. When using the max int value (2147483647) no records are returned. All above results in an error.

  • Christian Abeln Profile Picture
    on at

    Hello,

    please try not to implement any member operations based on observations when debugging and conjecture. 

    Used for static segments only, today on CRM side there resides a field "msdyncrm_segmentmemberids" on the CRM entity that contains as a Json list all the member contact IDs that the user in the UI has selected to be included into the segment. One might say that this is the exact selection of members which the segment would also carry in the backend. This is easy to parse e.g. in Power BI.
    But be warned - even that will probably change in the future, towards fall release 2019.

    Also for dynamic segments there is no supported way to programmatically request the members. 

    Try not to simulate what UI currently does to display members. This implementation WILL change behind the scenes.

    But I can feel you - it is fun to discover and experiment with those internal mechanics and try making use of them ;-)

  • Richard@BarheadAU Profile Picture
    160 on at

    Hey Christian - this is a real limitation of D365fM.  If we want to extract members of a segment into say Excel, the only way we have found is using PBI.  Can you tell me if there are any plans to address this?  It's easy to export from Marketing List members to Excel - something similar would be ideal....

  • Christian Abeln Profile Picture
    on at

    Hello Richard,

    Excel export is indeed a capability that we would like to support. And we are looking at that for a future release. So yes, we have that in our plans.  But at the moment I cannot confirm in which release it could be available.

  • Community Member Profile Picture
    on at

    Hi Christian,

    Similarly, will it be possible to retrieve all Segments that a contact is a member of? And also list of Customer journey's that a contact has been part of?

    At the moment we can see Segment Members from the Segment record but cannot see the same from Contact I believe. We only have interaction history there, which might be hard to analyze when there are many journeys..

    Thanks

    Isil

  • Rawish Kumar Profile Picture
    13,758 on at

    this should help: passion4dynamics.com/.../  

  • Community Member Profile Picture
    on at

    Which is actually what I posted above, but this is not supported. There's still no official documentation on how to retrieve members for dynamic segments: docs.microsoft.com/.../extend-segments

  • Verified answer
    Rawish Kumar Profile Picture
    13,758 on at

    what do you mean it is unsupported. and it has been included in the documentation post I opened a ticket with microsoft on this issue and also opened github issue on document( scroll down to the bottom of the documentation). I have been using it successfully using web api and org service.

    Thanks

  • Community Member Profile Picture
    on at

    Sorry, you are right. Imho the "Retrieve segment members" sub section is badly placed under the "Include/exclude segment members" main section, therefore it wasn't easy to find for me.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Insights - Journeys

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans