<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://customerfx.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ryan Farley&amp;#39;s Blog : Development, Customer Portal, Entity Model</title><link>http://customerfx.com/pages/crmdeveloper/archive/tags/Development/Customer+Portal/Entity+Model/default.aspx</link><description>Tags: Development, Customer Portal, Entity Model</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP2 (Build: 20611.960)</generator><item><title>Getting the Contact for the Currently Logged in Customer Portal User</title><link>http://customerfx.com/pages/crmdeveloper/2007/12/10/Getting-the-Contact-for-the-Currently-Logged-in-Customer-Portal-User.aspx</link><pubDate>Mon, 10 Dec 2007 17:35:00 GMT</pubDate><guid isPermaLink="false">e15581aa-2787-4c59-a940-524c09f5d256:38661</guid><dc:creator>Ryan Farley</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://customerfx.com/pages/crmdeveloper/rsscomments.aspx?PostID=38661</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://customerfx.com/pages/crmdeveloper/commentapi.aspx?PostID=38661</wfw:comment><comments>http://customerfx.com/pages/crmdeveloper/2007/12/10/Getting-the-Contact-for-the-Currently-Logged-in-Customer-Portal-User.aspx#comments</comments><description>&lt;p&gt;In the SalesLogix 7.2 Customer Portal, you might have the need to get or set values from the user&amp;#39;s contact record. While the user is actually a contact, in the portal, the SLXUserService is still used to get the logged in user. However, you&amp;#39;ll need to translate it&amp;nbsp;to an WebPortalUserService to be able retrieve the&amp;nbsp;IContact reference to work with the underlying contact record. &lt;/p&gt;
&lt;p&gt;Using the following code, you can retrieve the contact record for the logged in customer (in the customer portal):&lt;/p&gt;&lt;pre&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; Sage.SalesLogix.Security; &lt;span style="COLOR:green;"&gt;// for SLXUserService
&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; Sage.Platform.Security; &lt;span style="COLOR:green;"&gt;// for IUserService
&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; Sage.Platform.Application; &lt;span style="COLOR:green;"&gt;//for ApplicationContext
&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; Sage.SalesLogix.Web; &lt;span style="COLOR:green;"&gt;// for WebPortalUserService
&lt;/span&gt;&lt;span style="COLOR:blue;"&gt;using&lt;/span&gt; Sage.Entity.Interfaces; &lt;span style="COLOR:green;"&gt;//for IContact
//...
&lt;/span&gt;
SLXUserService service &lt;span style="COLOR:navy;"&gt;=&lt;/span&gt; ApplicationContext.Current.Services.Get&amp;lt;IUserService&amp;gt;(&lt;span style="COLOR:blue;"&gt;true&lt;/span&gt;) as SLXUserService;
&lt;span style="COLOR:blue;"&gt;if&lt;/span&gt; (service is WebPortalUserService)
{
    WebPortalUserService portalservice &lt;span style="COLOR:navy;"&gt;=&lt;/span&gt; (WebPortalUserService)service;
    IContact contact &lt;span style="COLOR:navy;"&gt;=&lt;/span&gt; portalservice.GetPortalUser().Contact;
    
    &lt;span style="COLOR:green;"&gt;// now do what is needed with the contact
&lt;/span&gt;    &lt;span style="COLOR:blue;"&gt;string&lt;/span&gt; whatever &lt;span style="COLOR:navy;"&gt;=&lt;/span&gt; contact.Something;
}&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Once you have the contact, you can do whatever is needed to read or write values to it.&lt;/p&gt;&lt;img src="http://customerfx.com/aggbug.aspx?PostID=38661" width="1" height="1"&gt;</description><category domain="http://customerfx.com/pages/crmdeveloper/archive/tags/Development/default.aspx">Development</category><category domain="http://customerfx.com/pages/crmdeveloper/archive/tags/New+Finds/default.aspx">New Finds</category><category domain="http://customerfx.com/pages/crmdeveloper/archive/tags/SalesLogix+Web/default.aspx">SalesLogix Web</category><category domain="http://customerfx.com/pages/crmdeveloper/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://customerfx.com/pages/crmdeveloper/archive/tags/Entity+Model/default.aspx">Entity Model</category><category domain="http://customerfx.com/pages/crmdeveloper/archive/tags/Customer+Portal/default.aspx">Customer Portal</category></item></channel></rss>