How to Terminate Client Session using X++ in Ax


If you would like to end the current session by code, you can do it like this:

staticvoid Shutdown(Args _args)
{
    Info Info = newInfo();
    ;
//WithOut Infolog
Info.shutDown(true);   

//With Infolog
Info.shutDown(false);   
}

If you want to Terminate Current Session by Code then you can try this code to terminate Current user Current Session. Create Job and run this code to terminate Session of Particular Client. Here you can set userid for terminate that use session.

staticvoidTerminateSession(Args _args)
{
xSessionxSession;
intxSessionId;
    ;
xSessionId = (select * fromSysClientSessionswhereSysClientSessions.userId=='umesh.ad'&&SysClientSessions.Status==1).SessionId;

xSession = new xSession(xSessionId);
if (xSession)
xSession.terminate(xSession.loginDate(), xSession.loginTime());

info(strFmt("%1",xSession.clientComputerName()));
info(strFmt("%1,%2",xSession.loginDate(), xSession.loginTime()));
}

Related Posts

Previous
Next Post »

Thanks for comments.....