Displaying username

A

Amod

Hi all,
I could find few comments here for this already but it didnt help. I am
trying to display the username value in Infopath form when it loads. I used
username() fuinction but it does not verify this formula.
Please suggest a way out for this.

Thanks
Amod Goyal
 
S

SMS

Hi all,
I could find few comments here for this already but it didnt help. I am
trying to display the username value in Infopath form when it loads. I used
username() fuinction but it does not verify this formula.
Please suggest a way out for this.

Thanks
Amod Goyal

Goto list of functions and choose all and Username will come. use that
function

The actual code for it is:
xdUser:get-UserName()
 
A

Amod

is it something specific to 2007 ver?
since I dont see that function in 2003 I am using currently
 
S

Swathi (GGK Tech)

Hi,

Yes, this function is included in InfoPath 2007. There is no such function
in InfoPath 2003.
 
A

Amod

Thanks for the replies.
OK, so any other way around to do in 2003? I donot want to save the previous
users, just want to display it on load event.
 
G

Guru

Thanks for the replies.
OK, so any other way around to do in 2003? I donot want to save the previous
users, just want to display it on load event.

Hi Amit,

To get username of Current login user use below code:

SPWeb oHRWeb = new SPSite("http://server:5656/sites/
sharepoint/").OpenWeb();
SPUser oSPUser = oHRWeb.CurrentUser;
oSPUser = oHRWeb.CurrentUser;
string username= oSPUser.Name;
 
S

Swathi (GGK Tech)

Hi,

You can get the current user login name using the following code line.
System.Environment.UserName;
 
S

Swathi (GGK Tech)

Hi,

You can get the current user login name using the following code line.
System.Environment.UserName;
 
G

Guru

Hi,

you can also get current user name by below code :

this.Application.User.UserName;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top