Saturday, June 13, 2009

Check to see if a user is logged on

In my previous post I talked about the class xSession. The help files for this class in Ax show a nice example for this: Check to see if a specific user id is online.

server static boolean isUserOnline(userId userId)
{ xSession session;
int counter;
int maxSessions = Info::licensedUsersTotal();
;

if (!userId)
{
return false;
}

for(counter = 1; counter < session =" new">

This example is a nice illustration for the use of the xSession class.
I came up with an alternative, shorter version for the example above:

server static boolean isUserOnline(userId userId)
{ ;
return (select count(recid) from SysClientSessions where SysClientSessions.userId==UserId && SysClientSessions.Status==1).RecId;
}

So, both functions give you an easy way of checking if a specific user is online in Axapta.

No comments:

Post a Comment