top of page
Writer's pictureEd G.

Getting Members of a D365 Marketing List (Static *AND* Dynamic) Using Power Automate.

Don't Call it a Comeback, I've been here for years.


Ok, not really. But it's still not really a comeback...yet. I started a new job in March (finally doing Power Platform stuff full time!) and it's taken most of my blogging/video/podcast time. The good news is that I get to work on even more cool projects and learn loads of things along the way. But, it means getting used to a blog format that supports small tidbits of information, rather than big walkthroughs. Today, for example, I found a neat trick for getting the members of a dynamic marketing list in Microsoft Dynamics 365 CE/Sales/CRM.


I found plenty of examples to grab the members of a static list, but nothing around dynamic lists, so I'm wondering if this feature is relatively new, or maybe I'm the only one using Marketing Lists still.

 

My project entailed going through each active campaign, and sending an adaptive card to the members, so the first struggle was figuring out how marketing lists are associated to the campaigns. Thanks to Matt Beard, I didn't have to struggle for long: That relationship is stored in the Campaign Item table, and we'll look for an "entity type" of Marketing List (value = 4300 in OOB D365). I leveraged FetchXML Builder in XRMToolbox to create the query below:

Screen shot of Dataverse action "List Rows" for Campaign Item table.
Note that I am using a dynamic value for the Campaign ID.

This step will provide a list of all of the marketing lists associated with that campaign, so the next step is to work through each of those to get a list of contacts. Since the method for a dynamic list is different from a static list, we need to first find which type of list it is.

 
Screenshot of the Apply to Each step for getting the details from each Marketing List.

Inside my Apply to Each loop, I have a Dataverse "Get Row by ID" step, using the Entity ID from my Campaign Items array. This gets the details for each respective marketing list. I'm not sure why, but "Type" is false for static lists, so I use that as my condition. I'm certain there are other, more elegant, ways...but this is my hammer.

 

For static lists, it's simply a matter of cycling through the listmember table where the listid is equal to the marketing list you're interested in.


I've used the dynamic value from my previous step in the Fetch XML query detailed to the left.








 

For dynamic lists, it's actually even easier. The marketing list record includes the Fetch XML query used to get the list of members, so we just need to drop that column in the Fetch XML Query field on the Dataverse List Rows action:

Dataverse List Rows action on the Contacts table using the Fetch XML query from the Marketing List Detail record

Keep in mind that marketing lists can consist of Leads or Contacts, so if you're expecting either/both, then you'll want to build in logic to account for that. In my scenario, we are only using Contacts, so I didn't have to build in a Leads path.

 

I hope this helps someone out there battling a similar scenario. It took some digging to get to this solution, but so far it seems pretty stable and effective.


Jump in, break things. Try. Fail. Learn. Repeat.

2,748 views3 comments

Recent Posts

See All

3 comentários

Avaliado com 0 de 5 estrelas.
Ainda sem avaliações

Adicione uma avaliação
Sandeep
Sandeep
20 de dez. de 2022

Hi Ed G, Great post! Can you please show the full FetchXML query to retrieve Dynamic Marketing List members? Sorry, It is not very clear in your blog. Thanks in advance!

Curtir
sneha dohale
sneha dohale
19 de jan. de 2023
Respondendo a

just get the 'query' column value from Marketing List Id.

ex. List Records where list = abc and in select columns 'query'


Put same query column result into Contact list query

Curtir
bottom of page