0

I'm trying to get the list of members of a dynamic marketing list. When it's only a single (or just a few) lists, I could fetch the results of the underlying query individually. However, when the number of marketing lists raises, the fetching one-by-one becomes quite ineffective.

For static marketing lists it should be straight-forward, I expect. I should be able to fetch all instances of the entity Contact (or whatever the base type used for its creation is) when filtering for a set of guids corresponding to all the marketing lists based on Contact in my QueryExpression object. Is that correctly perceived?

(How) can I fetch all the underlying members of all the dynamic list on the server?

enter image description here

EDIT: This is the automagically generated fetch-XML.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="account">
    <attribute name="name" />
    <attribute name="primarycontactid" />
    <attribute name="telephone1" />
    <attribute name="accountid" />
    <order attribute="name" descending="false" />
  </entity>
</fetch>
Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • I haven't dealt with marketing lists, is that a separate entity? Is can you write the equivalent SQL you're attempting to perform? – Daryl Jan 14 '13 at 16:41
  • @Daryl Yupp. Its schema name is *list* and it's an entity used for, well, marketing. It can target either *Contact*, *Account* or *Lead* (and perhaps *SystemUser*). and it's a real PIA. The problem of mine is mainly with the dynamic type, the members of which are declare by a fetch-XML (yes, there's an actual column that stores the stupid string - it's called *query*). As it's now, it forces me to execute that string for **every** marketing list separately and that's just not right for duck's sake! (You can find it under *Marketing* and *Sales*, if you're curious. I added image to my OP.) – Konrad Viltersten Jan 14 '13 at 18:10
  • Are you fetching from plugin? Also could you please provide one fetch-XML from some your marketing list? – SergeyS Jan 15 '13 at 05:51
  • @SergeyS Nope. I'm fetching from an add-on to Outlook (VSTO) but it's using the same SDK as the plugin coding. The fetch-XML I'm using for the members is the one that's created automatically by CRM. I've posted it as an update to my question. – Konrad Viltersten Jan 15 '13 at 07:31
  • @Konrad Viltersten - thanks, but I wanted to see exact fetch xml used inside dynamic marketing lists. If they all follow the same format, and only name of related entity is changing - then you can try to write some routine to combine all those fetches in one big fetch xml. – SergeyS Jan 15 '13 at 08:27
  • @SergeyS That is the actual content of the list view in SQL. My issue is that I'm not that good at fetchXML so I know how to put those calls together so that I get the listing of all members of all the lists (keeping the names of the list they belong to, so that Mr. Baboo is listed twice if he satisfies the condition of two different lists). ANy suggestions? – Konrad Viltersten Jan 15 '13 at 10:41
  • @Konrad Viltersten - Ok, I think that combining fetchxmls will be very difficult for your requirements (non-distinct return and keep name of marketing list members belong to). If you are saying that coding the same as in plugin - then I think it will be much easier for you to execute fetches one by one, and after that accumulate results in some collection. This way you will get a full control of your results and can easily transform/output them in appropriate way. I assume coding there in C# is possible, right? – SergeyS Jan 15 '13 at 11:36
  • @SergeyS Darn... Yes, C# is the way it's solved now - aggregating the results. My worry is that as the number of lists raises, so will the returning time. But I guess that's the only way. Put it as an answer so I can check it. – Konrad Viltersten Jan 15 '13 at 15:29

1 Answers1

1

Well, combining of FetchXML queries would be too difficult (if even possible) for your requirements (non-distinct records in results and keeping name of marketing list to which members belong to). Please note that according to documentation FetchXML query can be run against only one root entity (say Account or Contact), other entities can be only linked. Since you do not have direct links between Accounts and Marketing lists in the database (instead of that you have just a FetchXML string stored in DB), you will not be able to use link-entity for your job.

Assuming you are doing it now via C# code - this is actually a good way to go. It will give you more control on your data - you can rearrange/combine/convert easily. I think that you should not worry about performance. Several fetch xml executed one by one would not take much more time than a huge combined one may potentially take. Also if you implement collection manipulation wisely in C# you can achieve pretty good performance. I really do not think that combined huge FetchXML will give any performance benefits, but only difficulties to maintain.

SergeyS
  • 3,515
  • 18
  • 27