Getting the Contact for the Currently Logged in Customer Portal User

In the SalesLogix 7.2 Customer Portal, you might have the need to get or set values from the user’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’ll need to translate it to an WebPortalUserService to be able retrieve the IContact reference to work with the underlying contact record.

Using the following code, you can retrieve the contact record for the logged in customer (in the customer portal):

using Sage.SalesLogix.Security; // for SLXUserService
using Sage.Platform.Security; // for IUserService
using Sage.Platform.Application; //for ApplicationContext
using Sage.SalesLogix.Web; // for WebPortalUserService
using Sage.Entity.Interfaces; //for IContact
//...

SLXUserService service = ApplicationContext.Current.Services.Get<IUserService>(true) as SLXUserService;
if (service is WebPortalUserService)
{
    WebPortalUserService portalservice = (WebPortalUserService)service;
    IContact contact = portalservice.GetPortalUser().Contact;

    // now do what is needed with the contact
    string whatever = contact.Something;
}

 

Once you have the contact, you can do whatever is needed to read or write values to it.

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!