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
e.g.
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.
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
e.g.
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.