How to capture Login and Logout Time in navision 2017??

raja123raja123 Member Posts: 50
I tried to get the login time by adding C/al code in codeunit (1)ApplicationManagement -> CompanyOpen()

p4y9pnxnbxh8.png

but i cant replicate the same in CompanyClose() to get logout time.
Any suggestions will be helpful. :)

Answers

  • AlexDenAlexDen Member Posts: 85
    Hi,

    There is table 2000000111 "Session Event" where this information is already being saved.
  • raja123raja123 Member Posts: 50
    edited 2019-05-09
    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
    oxsur6b3dfkc.png

    Here LoginLogout is my custom table and i want to capture time details in this table .
    But its not working.
  • AlexDenAlexDen Member Posts: 85
    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;
    
  • raja123raja123 Member Posts: 50
    Hi AlexDen i tried what you mentioned (subscribe to those events)
    but getting this error while opening a client
    pdxt49e541j6.png
  • raja123raja123 Member Posts: 50
    hi Alex,
    onAftercompanyClose() is not executing.But OnafterCompanyOpen() is working.
Sign In or Register to comment.