<?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; SDK</title> <atom:link href="http://www.langalaxy.de/tag/sdk/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>Who triggered my plugin?</title><link>http://www.langalaxy.de/2009/09/who-triggered-my-plugin/</link> <comments>http://www.langalaxy.de/2009/09/who-triggered-my-plugin/#comments</comments> <pubDate>Sat, 12 Sep 2009 18:40:58 +0000</pubDate> <dc:creator>ckeller</dc:creator> <category><![CDATA[Dynamics CRM]]></category> <category><![CDATA[CRM 4]]></category> <category><![CDATA[Hints]]></category> <category><![CDATA[Plugins]]></category> <category><![CDATA[SDK]]></category><guid
isPermaLink="false">http://www.langalaxy.de/?p=256</guid> <description><![CDATA[Do you ever want to know who triggered the execution of a plugin? This knowledge is handy, if you have to do some operation if the user entered data, but not if an external application made an update with the SDK. The IPluginExecutionContext contains the property CallerOrigin which will tell us more about the origin [...]]]></description> <content:encoded><![CDATA[<p>Do you ever want to know who triggered the execution of a plugin? This knowledge is handy, if you have to do some operation if the user entered data, but not if an external application made an update with the SDK.</p><p>The <em>IPluginExecutionContext</em> contains the property <a
href="http://msdn.microsoft.com/en-us/library/cc156395.aspx">CallerOrigin</a> which will tell us more about the origin which triggered the plugin execution.</p><p>The CallerOrigin is populated with one of these four types</p><ul><li><a
href="http://msdn.microsoft.com/en-us/library/cc156328.aspx">Application</a> &#8211; The user has triggered the event (by creating or editing a record).</li><li><a
href="http://msdn.microsoft.com/en-us/library/cc156329.aspx">AsyncService</a> &#8211; The async service triggered the event (by workflow execution).</li><li><a
href="http://msdn.microsoft.com/en-us/library/cc156336.aspx">WebServiceApi</a> &#8211; An application which makes use of the crm web service triggered the event.</li><li><a
href="http://msdn.microsoft.com/en-us/library/cc153425.aspx">OfflineOrigin</a> &#8211; The event was triggered by replaying offline actions while going online.</li></ul><p>This sample shows how to make use of this property (the sample is part of the sdk article <a
href="http://msdn.microsoft.com/en-us/library/cc151093.aspx">Online vs. Offline Plug-ins</a>)</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Crm.Sdk</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">Microsoft.Crm.SdkTypeProxy</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> OnlinePlugin <span style="color: #008000;">:</span> IPlugin
<span style="color: #008000;">&#123;</span>
   <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Execute<span style="color: #008000;">&#40;</span>IPluginExecutionContext context<span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #008080; font-style: italic;">// Check to see if this is a playback context.</span>
      CallerOrigin callerOrigin <span style="color: #008000;">=</span> context<span style="color: #008000;">.</span><span style="color: #0000FF;">CallerOrigin</span><span style="color: #008000;">;</span>
&nbsp;
      <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>callerOrigin <span style="color: #008000;">is</span> OfflineOrigin<span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #008080; font-style: italic;">// This plug-in was fired from the playback queue after the user</span>
         <span style="color: #008080; font-style: italic;">// selected to go online within Microsoft Dynamics CRM for Outlook.</span>
         <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
      <span style="color: #0600FF; font-weight: bold;">else</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #008080; font-style: italic;">// Do something here.</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://www.langalaxy.de/2009/09/who-triggered-my-plugin/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Error 0x80044a08: &#8216;invalid character in file name&#8217;</title><link>http://www.langalaxy.de/2009/08/error-0x80044a08-invalid-character-in-file-name/</link> <comments>http://www.langalaxy.de/2009/08/error-0x80044a08-invalid-character-in-file-name/#comments</comments> <pubDate>Tue, 25 Aug 2009 17:43:07 +0000</pubDate> <dc:creator>ckeller</dc:creator> <category><![CDATA[Dynamics CRM]]></category> <category><![CDATA[CRM 4]]></category> <category><![CDATA[Hints]]></category> <category><![CDATA[SDK]]></category><guid
isPermaLink="false">http://www.langalaxy.de/?p=216</guid> <description><![CDATA[If you try to upload a file to a note in your crm system, you have to make sure that the property filename of the annotation only contains the filename. If it contains for example the drive letters you will receive the error 0x80044a08. The easiest way to ensure that the filename contains only the [...]]]></description> <content:encoded><![CDATA[<p>If you try to upload a file to a note in your crm system, you have to make sure that the property <a
href="http://msdn.microsoft.com/en-us/library/cc151511.aspx">filename</a> of the annotation only contains the filename. If it contains for example the drive letters you will receive the error 0x80044a08.</p><p>The easiest way to ensure that the filename contains only the file name is to use Path.GetFileName( &#8230; );</p><p>See the &#8216;corrected&#8217; sdk example below</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">// Open a file and read the contents into a byte array.</span>
FileStream stream <span style="color: #008000;">=</span> File<span style="color: #008000;">.</span><span style="color: #0000FF;">OpenRead</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;some-path-pointing-to-a-file-in-here&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> byteData <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> <span style="color: #6666cc; font-weight: bold;">byte</span><span style="color: #008000;">&#91;</span>stream<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
stream<span style="color: #008000;">.</span><span style="color: #0000FF;">Read</span><span style="color: #008000;">&#40;</span>byteData, <span style="color: #FF0000;">0</span>, byteData<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
stream<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// Encode the data using base64.</span>
<span style="color: #6666cc; font-weight: bold;">string</span> encodedData <span style="color: #008000;">=</span> <span style="color: #000000;">System</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Convert</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToBase64String</span><span style="color: #008000;">&#40;</span>byteData<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// Now update the note.</span>
annotation updateNote <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> annotation<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
updateNote<span style="color: #008000;">.</span><span style="color: #0000FF;">annotationid</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Key<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
updateNote<span style="color: #008000;">.</span><span style="color: #0000FF;">annotationid</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> createdNoteId<span style="color: #008000;">;</span>
updateNote<span style="color: #008000;">.</span><span style="color: #0000FF;">documentbody</span> <span style="color: #008000;">=</span> encodedData<span style="color: #008000;">;</span>
updateNote<span style="color: #008000;">.</span><span style="color: #0000FF;">filename</span> <span style="color: #008000;">=</span> Path<span style="color: #008000;">.</span><span style="color: #0000FF;">GetFileName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;some-path-pointing-to-a-file-in-here&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
updateNote<span style="color: #008000;">.</span><span style="color: #0000FF;">mimetype</span> <span style="color: #008000;">=</span> <span style="color: #666666;">@&quot;application\ms-word&quot;</span><span style="color: #008000;">;</span>
&nbsp;
service<span style="color: #008000;">.</span><span style="color: #0000FF;">Update</span><span style="color: #008000;">&#40;</span>updateNote<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://www.langalaxy.de/2009/08/error-0x80044a08-invalid-character-in-file-name/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>RetrieveMultiple Gotchas</title><link>http://www.langalaxy.de/2009/08/retrievemultiple-gotchas/</link> <comments>http://www.langalaxy.de/2009/08/retrievemultiple-gotchas/#comments</comments> <pubDate>Sun, 23 Aug 2009 14:18:57 +0000</pubDate> <dc:creator>ckeller</dc:creator> <category><![CDATA[Dynamics CRM]]></category> <category><![CDATA[CRM 4]]></category> <category><![CDATA[SDK]]></category><guid
isPermaLink="false">http://www.langalaxy.de/?p=182</guid> <description><![CDATA[This article is only relevant if you use the assemblies which are provided in the crm sdk The crm webservice provides multiple ways for querying data. One of them uses the QueryExpression for selecting the data. A QueryExpression can be used for retrieving data of any crm entity. However, if you use it to query [...]]]></description> <content:encoded><![CDATA[<p><em>This article is only relevant if you use the assemblies which are provided in the crm sdk</em></p><p>The crm webservice provides multiple ways for querying data. One of them uses the <a
href="http://technet.microsoft.com/en-us/library/bb929258.aspx">QueryExpression</a> for selecting the data.</p><p>A QueryExpression can be used for retrieving data of any crm entity. However, if you use it to query the entities <a
href="http://technet.microsoft.com/en-us/library/bb955732.aspx">activitypointer</a> or <a
href="http://technet.microsoft.com/en-us/library/bb957264.aspx">queueitem</a> your crm webservice proxy will throw an InvalidOperationException with the message <em>There is an error in XML document</em></p><p>So what are you doing wrong? Nothing.</p><p>This problem is (poorly) described in the sdkreadme.htm in the crm sdk.</p><blockquote><p>Possible failure using the CrmService.RetrieveMultiple method found in SdkTypeProxy.dll (32227)</p><p>Calling this method may result in an InvalidOperationException.</p><p>Workaround: Use the CrmService.Execute method with the RetrieveMultiple message instead.</p></blockquote><p>The described workaround leads to the same error. The only way to request data from these entities is to use DynamicEntities.<br
/> This requires a small change at your existing query: you only have to tell the CRM to return the results as DynamicEntities</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;">RetrieveMultipleRequest request <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> RetrieveMultipleRequest 
<span style="color: #008000;">&#123;</span> 
  Query <span style="color: #008000;">=</span> query, 
  ReturnDynamicEntities <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span> 
<span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://www.langalaxy.de/2009/08/retrievemultiple-gotchas/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>OpenThreadToken failed with hr = 1008</title><link>http://www.langalaxy.de/2009/08/openthreadtoken-failed-with-hr-1008/</link> <comments>http://www.langalaxy.de/2009/08/openthreadtoken-failed-with-hr-1008/#comments</comments> <pubDate>Sun, 23 Aug 2009 10:53:21 +0000</pubDate> <dc:creator>ckeller</dc:creator> <category><![CDATA[Dynamics CRM]]></category> <category><![CDATA[CRM 4]]></category> <category><![CDATA[SDK]]></category><guid
isPermaLink="false">http://www.langalaxy.de/?p=183</guid> <description><![CDATA[The crm sdk includes the class CrmImpersonator which allows to execute code with the crm user credentials instead the website credentials. If you have used this class, you may have come into situations in which the constructor has thrown an InvalidOperationException with the message OpenThreadToken failed with hr = 1008. A little research shows, that [...]]]></description> <content:encoded><![CDATA[<p>The crm sdk includes the class <a
href="http://msdn.microsoft.com/de-de/library/cc156363(en-us).aspx">CrmImpersonator</a> which allows to execute code with the crm user credentials instead the website credentials.</p><p>If you have used this class, you may have come into situations in which the constructor has thrown an InvalidOperationException with the message <em>OpenThreadToken failed with hr = 1008</em>. A little research shows, that the most common reason of this exception is that the CrmImpersonator only works if your website is executed in the context of the crm.</p><p>But even if the application runs in the context of crm there is a gotcha which leads to this exception. If you use a generic handler in your application and you are creating a new instance of the CrmImpersonator in the constructor of this handler, it will throw the same exception. See this example for reference</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>WebService<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">Namespace</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;http://tempuri.org/&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #008000;">&#91;</span>WebServiceBinding<span style="color: #008000;">&#40;</span>ConformsTo <span style="color: #008000;">=</span> WsiProfiles<span style="color: #008000;">.</span><span style="color: #0000FF;">BasicProfile1_1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Handler1 <span style="color: #008000;">:</span> IHttpHandler, IDisposable
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">private</span> CrmImpersonator _impersonator<span style="color: #008000;">;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> Handler1<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    _impersonator <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> CrmImpersonator<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> ProcessRequest<span style="color: #008000;">&#40;</span>HttpContext context<span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    context<span style="color: #008000;">.</span><span style="color: #0000FF;">Response</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;text/plain&quot;</span><span style="color: #008000;">;</span>
    context<span style="color: #008000;">.</span><span style="color: #0000FF;">Response</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Hello World&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsReusable
  <span style="color: #008000;">&#123;</span>
    get<span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
&nbsp;
  <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Dispose<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
  <span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>_impersonator <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
       _impersonator<span style="color: #008000;">.</span><span style="color: #0000FF;">Dispose</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
       _impersonator <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
  <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div><p>It seems that the thread which processes the request is not properly initialized at this point. The solution of this problem is simple. You have to create the CrmImpersonator in the ProcessRequest method of your handler.</p> ]]></content:encoded> <wfw:commentRss>http://www.langalaxy.de/2009/08/openthreadtoken-failed-with-hr-1008/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <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 417/462 objects using disk: basic

Served from: www.langalaxy.de @ 2012-02-07 02:46:05 -->
