Hi AlexDen ,
I created a event subscriber in codeunit and i'm trying to get the login and logout time after the record inserted in the 'session event' table
Here LoginLogout is my custom table and i want to capture time details in this table .
But its not working.
Raja, if I were you I would use events OnAfterCompanyOpen() and OnAfterCompanyClose() events from 1st codeunit to save this info.
And the code should be like that:
OnAfterCompanyOpen():
IF NOT ActiveSession.GET(SERVICEINSTANCEID,SESSIONID) THEN
EXIT;
LoginLogOut.INIT;
LoginLogOut."Session Unique ID" := ActiveSession."Session Unique ID"; // It's primary key
LoginLogOut."Session ID" := SESSIONID;
LoginLogOut."User ID" := USERID;
LoginLogOut."Login Time" := CURRENTDATETIME;
LoginLogOut.INSERT;
OnAfterCompanyClose():
IF ActiveSession.GET(SERVICEINSTANCEID,SESSIONID) THEN
IF LoginLogOut.GET(ActiveSession."Session Unique ID") THEN BEGIN
LoginLogOut."Logout Time" := CURRENTDATETIME;
LoginLogOut.MODIFY;
END;
Answers
There is table 2000000111 "Session Event" where this information is already being saved.
I created a event subscriber in codeunit and i'm trying to get the login and logout time after the record inserted in the 'session event' table
Here LoginLogout is my custom table and i want to capture time details in this table .
But its not working.
And the code should be like that:
OnAfterCompanyOpen():
OnAfterCompanyClose():
but getting this error while opening a client
onAftercompanyClose() is not executing.But OnafterCompanyOpen() is working.