Unified Service Desk – Logged in user details in Hosted controls

Hi,

You may need Logged in user details for different purposes in hosted controls.

Here is the way to get them from replaced parameters.

// This will give you actual logged in customer

var customer = (Microsoft.Crm.UnifiedServiceDesk.Dynamics.DynamicsCustomerRecord)localSession.Customer.DesktopCustomer;
Dictionary<string, CRMApplicationData> userInfo = null;
if (!customer.CapturedReplacementVariables.TryGetValue(“$User”, out userInfo))
return;

CRMApplicationData fullname = null;
if (!userInfo.TryGetValue(“fullname”, out fullname))
return;

CRMApplicationData userId = null;
if (!userInfo.TryGetValue(“systemuserid”, out userId))
return;

Dictionary<string, CRMApplicationData> systemUserInfo = null;
if (!customer.CapturedReplacementVariables.TryGetValue(“systemuser”, out systemUserInfo))
return;

Happy coding..!

Sreeni Pavalla

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s