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 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
}
-----------------------------------------------
I have the same question (0)
  • Suggested answer
    Sayen Zhang Profile Picture
    on at

    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

  • Suggested answer
    Community member Profile Picture
    10 on at
    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 96 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans