WebMasterSam

.Net, SEO, Dynamics CRM, AdSense/AdWords, Dating sites, Silverlight, Web hosting and more

About me

I'm an IT consultant working primarily with the .Net Framework as a developper and architect. I also work on my own on my personnal dating websites. I've been developping websites since 2000.

If you like what I do, feel free to support me

PayPal - The safer, easier way to pay online!

Bookmark

Bookmark and Share

Last comments

None

How to get the username client-side in Microsoft Dynamics CRM 4.0

In CRM 4.0, when you want to know to NT username of the currently logged in user with JavaScript, you need
to issue a request to the server. This sounds (and IS) ridiculous and also no performant.

The solution I've developped is a lot more performant because you don't need to call (AJAXly) the server
to get the username of the current user.

HttpModules...
For a lot of things in CRM we've used HttpModules to inject some JavaScript code onto the CRM pages (in the <head> tag).
For the currently logged in user we just inject this line of .Net code : [HeadTag].AppendFormat("var USERNAME='{0}';", My.User.Name);

The [HeadTag] is a class that we developped to encapsulate the stream property named "Filter" of the HttpResponse object, accessible
on the HttpModule. This property contains the HTML to is about to be sent to the client so we use this to inject our JavaScript code.

With this solution, in each page in CRM you have a JavaScript variable called USERNAME that you can use to have the username !

You can also do the same thing to have the current computer name.
Posted: Apr 09 2009, 19:51 by WebMasterSam | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .Net | CRM 4.0 | JavaScript
Social Bookmarks: E-mail | Kick it! | DZone it! | del.icio.us
LINK BUILDING IS PROHIBITED ON THIS WEBSITE