Export Segment members from Dynamics Marketing

DatabaseDesign_Infographic-1All my customers are usually asking how to export members of the segments to excel or CSV. This feature is also requested by people at experience.dynamics.com, and so far is planned for April 2020. You can read more here: Ability to export Segment members to Excel. In this article, I would like to show you how you can build a fetchxml which will export members data from the segment.

As segments are operated outside the Power Platform, there should be a way how Power Platform can interact with them, so Microsoft decided to use contact entity for this. Every time you request members of the segment, you actually request the contacts with some additional parameters. These parameters then parsed by the special RetrieveMultiple plugin and query is redirected to the internal marketing services. I will not go into the details and just give you an example which will return members of the segment.

<fetch version='1.0' output-format='xml-platform' 
                            mapping='logical' 
                            page='1' 
                            count='5' >
    <entity name='contact'>
        <attribute name='fullname'/>
        <attribute name='emailaddress1'/>
        <link-entity name='msdyncrm_segment' 
                                             from='msdyncrm_segmentid' 
                                             to='msdyncrm_segmentmemberid' 
                                             alias='ab'>
            <filter type='and'>
                <condition attribute='msdyncrm_segmentid' 
                                               operator='eq' 
                                               uitype='msdyncrm_segment' 
                                               value='6915ca6d-8d3e-e911-a966-000d3aba03c4'/>
            </filter>
        </link-entity>
    </entity>
</fetch>

Just replace the GUID you see in the fetchxml with yours, and it will return the members of your segment. The segment should be live. Unfortunately, you can’t recreate such request with Advance find as there should be two additional parameters page and count. Without these parameters, the system will always return 0 contacts. So now you are aware of how to export members of the segment! You can build a tool or even RetrieveMultiple plugin which can override some special request and return members of the segment into the standard grid from which you can export it to excel.

Leave a Reply

Your email address will not be published. Required fields are marked *