Link to home
Start Free TrialLog in
Avatar of sbdt8631
sbdt8631

asked on

Dynamics CRM 4.0 Java Code to Get User Name

I thought this would be easy but using Google isn't working for me to find a correct answer.  What code can I put in the OnLoad event of the form that will store the current user name in a variable that I can use in an If statement?
ASKER CERTIFIED SOLUTION
Avatar of Feridun Kadir
Feridun Kadir
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sbdt8631
sbdt8631

ASKER

I saw that one but it seems like complete overkill just to get the user name.

This one promised to do it but delivered a generic error.
http://social.microsoft.com/Forums/en/crmdevelopment/thread/e819f5f9-2270-485e-afd8-46b0ec795f9e
var cmd = new RemoteCommand("SystemUser", "WhoAmI", "/MSCRMServices/");
var res = cmd.Execute();
if (res.Success)
return res.ReturnValue.UserId;

I found various examples of this but always get System is Undefined
http://stackoverflow.com/questions/797549/get-login-username-in-java
System.getProperty("user.name")
I think remotecommand may be unsupported so I wouldn't go down that route.
Your second link refers to java not javascript.

I don't see that you have any other option.
Thank you