Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Filter Members in Segment

(0) ShareShare
ReportReport
Posted on by 25

Dears, I am using below code to get Segment members but how can I apply filter on it? I tried to add condition in the fetchXML but it neglected it as if it doesn't exist. I even tried to add .FILTER() on the query but it returned an error that query is not correct. 

Eventually, I need to get all segments where current contact is part of, but my segments are dynamic not static so they are changing every while.

-----------------------------------------------------------------------------

Retrieve segment members (recommended)

HTTPCopy
POST {{OrgUrl}}/api/data/v9.0/msdyncrm_FetchContactsByQuery
{
    "Query":"(SEGMENT(SEGMENT_CRM_ID_e1fa7fdc5c78ea11a811000d3a8e8fcc)).ORDERBY(fullname ASC).SKIP(0).TAKE(15).SELECT(contactid)",
    "FetchXml":"<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\" count=\"15\" page=\"1\" returntotalrecordcount=\"true\"><entity name=\"contact\"><attribute name=\"fullname\"/><attribute name=\"emailaddress1\"/><attribute name=\"company\"/><attribute name=\"parentcustomerid\"/><attribute name=\"contactid\"/><order attribute=\"fullname\" descending=\"false\"/></entity></fetch>","OwningBusinessUnit":"0b4b85cc-7f6c-ea11-a811-000d3a54d359",
    "Scope":270100000,
    "TimeZone":null
}
-----------------------------------------------
  • Suggested answer
    Community member Profile Picture
    10 on at
    Filter Members in Segment
    Hi Sohs,

    The approach you are using is for Outbound segments it won't work for real time segments.

    For outbound segment :- The issue in your fetchxml seems is SEGMENT_CRM_ID_e1fa7fdc5c78ea11a811000d3a8e8fcc, you need to retrieve this seg id from the record and put in a variable according to the format.

    for realtime segments :- you can refer to the below link.
    https://medium.com/@anshulasethi/streamlining-real-time-segment-member-retrieval-in-ms-crm-ce4d13f3c36a
  • Suggested answer
    Sayen Zhang Profile Picture
    on at
    RE: Filter Members in Segment

    Hi Soha,

    According to your first question: how to use code to get segment members, you can refer to this fetch xml:

    <fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\">" +

                "<entity name=\"contact\">" +

                "<attribute name=\"fullname\"/>" +

                "<attribute name=\"emailaddress1\"/>" +

                "<attribute name=\"company\"/>" +

                "<attribute name=\"parentcustomerid\"/>" +

                "<attribute name=\"contactid\"/>" +

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

                "</entity>" +

    "</fetch>";

    You can also refer to this link: FetchXml to retrieve segment member - Dynamics 365 Marketing Forum Community Forum

    In additional, it is available for us to add http that you offered in power automate flow to get contacts, please refer to this link: How are Segments and Contacts related - I want to loop though contacts that are part of an segment with power automate - Dynamics 365 Marketing Forum Community Forum

     

    According to your second question, we can use “Web API” to get all segments where contact is part of no matter dynamic or static. Here are the steps that you can followed:

    1. Go to Power Apps home page.

    2. Click gear to select session details.

    3. Copy Instance URL.

    4. Enter the URL before “/api/data/v9.0/msdyncrm_segments”.

    pastedimage1681368454806v1.png

    5. If segments where contact is not part of, contact is not contained in segment’s profile.

    pastedimage1681368473390v2.png

    If you have any questions, you can also reply to let us know. Thank you!

     

    Best Regards,

    Sayen Zhang

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,137 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,877 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans