How to change the current user using code

Hi All,

Is it possible to change the current user using some code of X++ . Suppose, when ax starts it shows the current user as the one who loged in from windows lets say “xyz” now i want to change the user to “abc” using some code.

Thanks in Advance

Hi Vikrant,

I didn’t understand why you want to change the current userid. According to me once your user id gets updated with different value then you could not able to view AX.

Dear Vishal ,

Thanks For reply, My actual requirement is to only change the name of current user …actually situation is like my client wants that more than one user can use same system but every user must use his username while operating the ax so that transaction performed by him can be traced …so i was thinking to provide and interface by which we can swap the current user

Any Help will be appreciated :slight_smile:

Thanks

Dear Vishal ,

Thanks For reply, My actual requirement is to only change the name of current user …actually situation is like my client wants that more than one user can use same system but every user must use his username while operating the ax so that transaction performed by him can be traced …so i was thinking to provide and interface by which we can swap the current user

Any Help will be appreciated :slight_smile:

Thanks

Vikrant,

Got to know your issue, But according to me instead of changing the userId in AX. Why don’t you log on to same machine with different userid evrytime.

Probably this way you could open the AX Session with different user id and thus the transactions could be recorded perfectly.

Dear Vishal You are right but this client is a big A** hole he says i dont want to re start my system actually he very stubborn for his requirement …any idea friend how to do this

Thankyou

Ok Vikrant, But no need to restart the system you need to choose the option “Run as different user” in the pop-up menu

(shown pressing the Shift key while doing a right-hand click) of the Dynamics AX icon.

dear Vishal There is o run as option …client OS is windows 7 …is there some catch for enabling run as option …secondly can we achieve my requirement with x++ code ??

Drag your Ax icon on to desktop and before right click press shift and then choose the option “Run as different user” in the pop-up menu.

I don’t think we can achieve it through code but you can still try using Xsession class.

Dear Vishal

xsession class has only 7 method and i dont think any of these can serve my purpose any way I will try thanks for help