How to Find the Userid or Username of the system by coding in X++?

I want to insert the username or userid into table

i used this code to find the username of the system

curuserid();

this is not working…i want to find the username or userid of the system using coding of X++

Hi Manimaranvasan,

Try this code in Job

print xUserInfo::find().id;

print xUserInfo::find().name;

pause;

Hi Manimaranvasan,

It will work. I don’t how r u using that method. Better try the below code in job and apply it to your object if it works fine.

str s;

;

s = curUserId();

info(strFmt("%1", s));

Try this in job. Hope it works.

If you want the name of the userid, try the below code in job.

str s;

;

s = xUserInfo::find().name;

info(strFmt("%1", s));