Options

NAV 2013 Active Session

nboettchernboettcher Member Posts: 14
edited 2014-08-20 in NAV Three Tier
I am trying to use the Active Session table from C/AL Code in NAV 2013.
I am doing the following:


ActiveSession.SETRANGE("Session ID", SESSIONID);
ActiveSession.FINDFIRST;
ServerName :=ActiveSession."Client Computer Name";

However, when that code is executed I get the following error:
"There is no Active Session within the filter. Filters: Session ID: 1"

If I look in SQL at the Active Session table, there aren't any entries. I have restarted the NAV Service multiple times.
Any ideas?

Comments

  • Options
    gideongideon Member Posts: 17
    Hi,

    The problem here is that you are forcing your session id filter to 1. Even if there are more that 1 session actually connected they might not be on session id 1. Where do you get this value from ?
  • Options
    SogSog Member Posts: 1,023
    I have some problems understanding why there is not always an active connection on the connection one is on. But the answer of gideon looks a bit odd, since the SESSIONID is a rather undocumented DATABASE variable. (I've looked in the help for SESSIONID, it's not there, even though it is a valid DATABASE variable)

    So this question remains, because I get this error when calling similar functionality in a SOAP session.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • Options
    SiStSiSt Member Posts: 46
    What do you want to achieve? The client has no database connection, only the service-tier has one.
    As far as I know, the SESSIONID is deprecated and also the virtual table session is gone.

    If you want to get the host name of the client you might need to use an automation/.net that runs on the client, like described here: http://www.dynamics.is/?p=282.
  • Options
    SogSog Member Posts: 1,023
    SiSt wrote:
    What do you want to achieve? The client has no database connection, only the service-tier has one.
    As far as I know, the SESSIONID is deprecated and also the virtual table session is gone.

    If you want to get the host name of the client you might need to use an automation/.net that runs on the client, like described here: http://www.dynamics.is/?p=282.

    I'm working with soap calls. and I require the database name. But regardless that it's always the same name for one instance, I must have it for the current session.
    If SessionID is depreciated, I would greatly appreciate if you could point me to documentation about that.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • Options
    SiStSiSt Member Posts: 46
    The session table is documented for NAV2009 (http://msdn.microsoft.com/en-us/library/dd338636.aspx) but it isn't for 2013, which let me believe that they do not support it any longer.

    But I guess I was wrong, as they are some people using it with 2013.

    But I guess there is a simpler way, at least in 2013R2 exists a virtual table Database (ID 2000000048), you can try to filter it for "My Database" = true. And read out the name of the Database.
  • Options
    Anatoliy_EAnatoliy_E Member Posts: 5
    hey,
    Looks like I have similar problem. Guys, can I search for any ActiveSession usage with C/SIDE?
    I am absolutely unfamiliar with NAV, help please.
    If I understood correctly all NAV code is in codeUnits, but I can't understand what invokes them.
  • Options
    Anatoliy_EAnatoliy_E Member Posts: 5
    solved

    OnAfterGetRecord trigger of Company Information page runs following code when System Indicator is "Company + Database" :
    ActiveSession.SETRANGE("Session ID",SESSIONID);
    ActiveSession.FINDFIRST;
    

    The code causes the error.

    At Company Information page edit form I've changed System Indicator field value from "Company + Database" to "Company".
  • Options
    NightriderNightrider Member Posts: 10
    @Anatoliy_E
    Agreed, that's a good solution. I have done this too. In the past if I ever needed the DB name in C/AL, I'd just add it as a new text field to Company Info. Don't know if there's a better solution.
    Regards,
    Vincent Connell
  • Options
    archer89archer89 Member Posts: 337
    it can be that the records in table active session where removed.
    so, close the windows client, restart it.
    then try again.
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
    Blog: http://moxie4nav.wordpress.com/
Sign In or Register to comment.