<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Trace.WriteLine(_blogTitle); &#187; Marketing</title> <atom:link href="http://www.langalaxy.de/tag/marketing/feed/" rel="self" type="application/rss+xml" /><link>http://www.langalaxy.de</link> <description>Random output</description> <lastBuildDate>Fri, 28 Oct 2011 17:20:03 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Howto: Retrieve members of a marketing list</title><link>http://www.langalaxy.de/2009/07/howto-retrieve-members-of-a-marketing-list/</link> <comments>http://www.langalaxy.de/2009/07/howto-retrieve-members-of-a-marketing-list/#comments</comments> <pubDate>Thu, 16 Jul 2009 16:43:35 +0000</pubDate> <dc:creator>ckeller</dc:creator> <category><![CDATA[Dynamics CRM]]></category> <category><![CDATA[CRM 4]]></category> <category><![CDATA[en]]></category> <category><![CDATA[Hints]]></category> <category><![CDATA[HowTo]]></category> <category><![CDATA[Marketing]]></category> <category><![CDATA[SDK]]></category><guid
isPermaLink="false">http://www.langalaxy.de/?p=153</guid> <description><![CDATA[Retrieving the members of a marketing list is for one reason a little bit trickier than retrieving other entities: there are no messages for operating with the listmember entity. Once you have loaded the marketing list, for which you want to retrieve the members, you have to find out of what type the members are. [...]]]></description> <content:encoded><![CDATA[<p>Retrieving the members of a marketing list is for one reason a little bit trickier than retrieving other entities: there are no messages for operating with the <a
title="listmember" href="http://msdn.microsoft.com/de-de/library/bb957095(en-us).aspx">listmember</a> entity.</p><p>Once you have loaded the marketing list, for which you want to retrieve the members, you have to find out of what type the members are. The type of the members is stored in the <a
title ="membertype" href="http://msdn.microsoft.com/de-de/library/cc153303(en-us).aspx">membertype</a> property of the marketing list.</p><p>Following method returns the name of the member entity type</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">internal</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetMemberType<span style="color: #008000;">&#40;</span>CrmNumber crmNumber<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>crmNumber<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">case</span> ListType<span style="color: #008000;">.</span><span style="color: #0000FF;">Account</span><span style="color: #008000;">:</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> EntityName<span style="color: #008000;">.</span><span style="color: #0000FF;">account</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">case</span> ListType<span style="color: #008000;">.</span><span style="color: #0000FF;">Contact</span><span style="color: #008000;">:</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> EntityName<span style="color: #008000;">.</span><span style="color: #0000FF;">contact</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">case</span> ListType<span style="color: #008000;">.</span><span style="color: #0000FF;">Lead</span><span style="color: #008000;">:</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> EntityName<span style="color: #008000;">.</span><span style="color: #0000FF;">lead</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">:</span>
            <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div><p>With this information we can create the <a
href="http://msdn.microsoft.com/de-de/library/bb929258(en-us).aspx">query expression</a> which we use to retrieve the list members.</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;">BusinessEntityCollection RetrieveMembers<span style="color: #008000;">&#40;</span>list marketinglist<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
&nbsp;
 <span style="color: #6666cc; font-weight: bold;">string</span> targetEntity <span style="color: #008000;">=</span> GetMemberType<span style="color: #008000;">&#40;</span>marketinglist<span style="color: #008000;">.</span><span style="color: #0000FF;">membertype</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
 QueryExpression query <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> QueryExpression
 <span style="color: #008000;">&#123;</span>
   EntityName <span style="color: #008000;">=</span> targetEntity<span style="color: #008000;">;</span>
   ColumnSet <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> AllColumns<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
 <span style="color: #008080; font-style: italic;">// link from target entity to listmember</span>
 LinkEntity linkToListMemberEntity <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> LinkEntity
 <span style="color: #008000;">&#123;</span>
   LinkFromEntityName <span style="color: #008000;">=</span> EntityName<span style="color: #008000;">.</span><span style="color: #0000FF;">account</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   LinkFromAttributeName <span style="color: #008000;">=</span> targetEntity <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;id&quot;</span><span style="color: #008000;">;</span>
   LinkToEntityName <span style="color: #008000;">=</span> EntityName<span style="color: #008000;">.</span><span style="color: #0000FF;">listmember</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   LinkToAttributeName <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;entityid&quot;</span><span style="color: #008000;">;</span>
 <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
 <span style="color: #008080; font-style: italic;">//link from listmember to list</span>
 LinkEntity linkToMarketingList <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> LinkEntity
 <span style="color: #008000;">&#123;</span>
   LinkFromEntityName <span style="color: #008000;">=</span> EntityName<span style="color: #008000;">.</span><span style="color: #0000FF;">listmember</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   LinkFromAttributeName <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;listid&quot;</span><span style="color: #008000;">;</span>
   LinkToEntityName <span style="color: #008000;">=</span> EntityName<span style="color: #008000;">.</span><span style="color: #0000FF;">list</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
   LinkToAttributeName <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;listid&quot;</span><span style="color: #008000;">;</span>
 <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
 <span style="color: #008080; font-style: italic;">// filter result with the id of the marketing list</span>
 ConditionExpression marketingListIdCondition <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ConditionExpression
 <span style="color: #008000;">&#123;</span>
   AttributeName <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;listid&quot;</span><span style="color: #008000;">;</span>
   <span style="color: #0600FF; font-weight: bold;">Operator</span> <span style="color: #008000;">=</span> ConditionOperator<span style="color: #008000;">.</span><span style="color: #0000FF;">Equal</span><span style="color: #008000;">;</span>
   Values <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> marketinglist<span style="color: #008000;">.</span><span style="color: #0000FF;">listid</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
 <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
 linkToMarketingList<span style="color: #008000;">.</span><span style="color: #0000FF;">LinkCriteria</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FilterExpression<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
 linkToMarketingList<span style="color: #008000;">.</span><span style="color: #0000FF;">LinkCriteria</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Conditions</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>marketingListIdCondition<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
 linkToListMemberEntity<span style="color: #008000;">.</span><span style="color: #0000FF;">LinkEntities</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>linkToMarketingList<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
 query<span style="color: #008000;">.</span><span style="color: #0000FF;">LinkEntities</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>linkToListMemberEntity<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
 BusinessEntityCollection members <span style="color: #008000;">=</span> service<span style="color: #008000;">.</span><span style="color: #0000FF;">RetrieveMultiple</span><span style="color: #008000;">&#40;</span>query<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
 <span style="color: #0600FF; font-weight: bold;">return</span> members<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://www.langalaxy.de/2009/07/howto-retrieve-members-of-a-marketing-list/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 261/275 objects using disk: basic

Served from: www.langalaxy.de @ 2012-02-07 02:57:04 -->
