Getting Hold of User Information in Code

Hints, Tips and Tricks

Technical Hints Tips and Tricks that cover customization and development using Sage CRM. API usage and coding are covered.

Getting Hold of User Information in Code

  • Comments 2
  • Likes
If you need to control the display of screen elements like buttons in ASP pages (or even client side in the browser screens) according to the identity of the CRM users then you will obviously need to be able to access the current user id.

In ASP pages you can get hold of user information by using context Information

var intRecordId = CRM.GetContextInfo("user","user_userid");

There is a special usage of GetContextInfo() for use in the My CRM area when building pages that need to synchronise with the user selected from the context area.

var intRecordId = CRM.GetContextInfo("selecteduser","user_userid");

In Create, Validate and other Server side scripts then we can also use the CurrentUser object


if (CurrentUser.user_logon == "Mayes")
Valid = false;
ErrorStr = CRM.GetTrans("CustomErrors","BlockSusan");

This CurrentUser object is also carried through to the browser and can be used in Custom Content scripts and onChange scripts.
  • Hey Jeff, in 7.1 i get "eWare" is undefined message when i try to use your example. Which file do i have to include in custom content (for example on oppo summary screen) to have eware object available on client side?

  • Sebastian

    The eWare object is a server side object so available inside the client.  You would use this script example in a Field Level Create script or in a Table Level script.