• Home
  • About Me
  • Contact Me
  • Downloads
  • White Papers
  • Web Sites
  • Post List
  • Articles
  • FAQ

Olof Simren - Microsoft Dynamics 365 Business Central Blog

  • Home
  • About Me
  • Contact Me
  • Downloads
  • White Papers
  • Web Sites
  • Post List
  • Articles
  • FAQ

Kill Sessions in Dynamics NAV

January 18, 2015 Posted by Olof Simren Development, General 31 Comments

In the older versions of Microsoft Dynamics NAV where the classic client was available you could go to the sessions table and just delete a session to kill it. This was very useful for a number of reasons but it does not work like that anymore in the windows client of version 2013 and 2015.

Fortunately this feature can easily be replicated by adding an action item to the ribbon on the sessions page in Dynamics NAV.

Here is how you can add a ‘Kill Session’ action item to the sessions page:

Open page 9506 in design mode through the development environment and add a ‘Kill Session’ action item. Something like below.

Kill-Session-Action-Dynamics-NAV

Then write the following code to the action item.

Kill-Session-Code-Dynamics-NAV

The above text constant Text50000 just says ‘Kill Session?’.

To make the action item look a bit better you might also want to set the Image and Promotion properties, like below.

Kill-Session-Properties-Dynamics-NAV

That’s it! 🙂

Now when you run the sessions table you can use the new ‘Kill Session’ action item in the ribbon to kill a session. Useful if a session is hanging or has been idle for a while. Also very useful if you start the job queue with a client and you want to stop the background session that is running.

Kill-Session-In-Dynamics-NAV

Nice! 🙂

Share this:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X

Related


Discover more from Olof Simren - Microsoft Dynamics 365 Business Central Blog

Subscribe to get the latest posts sent to your email.

Tags: DevelopmentSessionUsers
31 Comments
Share
12

About Olof Simren

I am a Microsoft Dynamics NAV and 365 Business Central Expert, I started implementing Microsoft Dynamics NAV in 2002, back then it was called Navision Attain. Throughout the years there has been many exciting implementations in different parts of the world, all of them with different challenges but with one common theme; manufacturing. As a consultant, I bring over 20 years of experience in implementing Microsoft Dynamics NAV and 365 Business Central within manufacturing and distribution companies. The services I offer includes project management, consultation, development and training. Feel free to contact me if you need help with anything related to Microsoft Dynamics NAV or 365 Business Central. I work through my company Naviona where I team up with other skilled Microsoft Dynamics NAV and 365 Business Central Experts.

You also might be interested in

Custom Business Chart Add-In Example for NAV 2013 R2

May 28, 2014

Here is an example of how to create a custom[...]

View Change Log from Ribbon

Apr 25, 2014

The Change Log in Microsoft Dynamics NAV is used to[...]

Add Fields to the Item Tracking Lines

Jun 7, 2016

This blog post is to describe how fields can be[...]

31 Comments

Leave your reply.
  • Lars Westman
    · Reply

    January 19, 2015 at 2:11 AM

    Thanks Olof! That’s a nice one!

    /Lars

  • Daniel Lennartsson
    · Reply

    January 19, 2015 at 3:03 AM

    Hi Olof

    We used this at some customers and it works fine in almost every case but one of the customers had “Load Balancing” on the two NAV servers and then you need to be connected to the same instance as the user you are going to “Kill”.

    / Daniel

    • Olof Simren
      · Reply

      Author
      January 19, 2015 at 8:11 AM

      Hi Daniel,
      Good to know, many thanks for your input!

      /Olof

  • Rafał
    · Reply

    January 20, 2015 at 3:01 AM

    Great idea! Thanks

  • Helle
    · Reply

    February 3, 2015 at 3:19 AM

    Hi Daniel,
    We run NAV 2013 and only do a run of the “Active Session” table 2000000110. Select the session to kill and press delete in the ribbon. That seems to work for us.

    • Rune C. Foyn
      · Reply

      March 6, 2015 at 3:32 AM

      Olof, would you like to comment on the difference between simply deleting a record in the table “Active Session” and running the system function STOPSESSION? Perhaps the latter makes sure certain things are cleaned up and rolled back, while the former is too violent??

      • Olof Simren
        · Reply

        Author
        March 6, 2015 at 9:45 AM

        Hi Rune,
        Interesting question.
        STOPSESSION does a proper close of a session; I am not sure what happen if you run the table and just delete a record. I would recommend using the STOPSESSION function since it is native NAV.
        If I find the difference I will post it here. If someone knows, feel free to reply with a comment! 🙂
        /Olof

  • Kamal
    · Reply

    March 14, 2015 at 1:17 PM

    Hi,

    I want to know how to get idle time of the session?as it is available in 4.0 but not available in uper version.

    • Kamal
      · Reply

      May 19, 2015 at 3:14 PM

      Please reply experts on my issue

      • Olof Simren
        · Reply

        Author
        May 19, 2015 at 3:35 PM

        Hi Kamal,
        I don’t know a way to get the idle session time. If someone else knows, feel free to leave a reply! 🙂
        What I do know is that you can configure session timeouts to close idle sessions automatically, see:
        https://msdn.microsoft.com/en-us/library/dn584639%28v=nav.71%29.aspx
        Not exactly an answer to your question, but maybe it can reduce the need for keeping track on how long they have been idle.

        /Olof

  • Anita
    · Reply

    May 18, 2015 at 6:12 PM

    Hi, We are running Nav 2009. We are having a similar problem. A user logs on and multiple sessions are created. When sessions are created for the same user, is the user also utilizing a license as well? How can we restrict the same user from creating multiple sessions or not use another license when logged on? I apologize if this is a duplicate question already addressed on the forum.

    • Olof Simren
      · Reply

      Author
      May 19, 2015 at 7:44 AM

      Yes, it utilizing a license. If you want to prevent users to log in twice you need to do a modification or to buy an add-on (just Google it and you will find many solutions for this).

      /Olof

  • Anita M Bailey
    · Reply

    May 19, 2015 at 3:09 PM

    Hey Oluf

    Thank you for getting back to me! Another question? Please forgive if it seems redundant. Does the extra sessions in Navision affect the number of Windows user logons possible?

    • Olof Simren
      · Reply

      Author
      May 19, 2015 at 3:37 PM

      Yes, Dynamics NAV uses concurrent users. If you logged in multiple times with the same windows user, or with different windows users does not really matter to the count.

      /Olof

  • Ricky
    · Reply

    January 7, 2016 at 1:32 AM

    Hi Olof, I dont know why when i make it, it doenst appear in the ribbon, i already follow instruction for code and property, currently using NAV 2015

    • Olof Simren
      · Reply

      Author
      January 7, 2016 at 5:41 PM

      Hi Ricky,
      Not sure why it does not show up. Maybe it is ‘hiding’ under another tab, that is all I can think of right now.

      /Olof

  • George
    · Reply

    January 8, 2016 at 7:35 AM

    Hello Olof,
    I have followed your instruction step by step and, as Ricky said, it does not show on the ribbon. In preview mode is showing on Action tab (next to Home), but in the interface only the Home is available and no sign of change. Strange, indeed..

    • Lars
      · Reply

      January 8, 2016 at 8:13 AM

      Hi George.

      Are you sure that you have put the code in the OnAction trigger?

  • George
    · Reply

    January 13, 2016 at 10:10 AM

    Now is working, it was a problem of page display. Thanks. 🙂

  • Arne Damkjer
    · Reply

    September 21, 2016 at 7:10 AM

    Feature: You could expand the STOPSESSION command with a note about who killed the session:

    STOPSESSION(“Session Id”,STRSUBSTNO(Text50001,USERID))

    where Text50001 is a text variable with a content like: “Session killed by user %1”

    The comment is stored in Table 2000000111, the Session Event table

  • Anthony A Montalto
    · Reply

    January 5, 2017 at 1:56 AM

    Thanks! I had an instant answer to what I needed to do 🙂

  • Andre
    · Reply

    January 26, 2017 at 10:17 AM

    Thank you very much, it just helped me with a problem with NAV2017!

  • Kavisha
    · Reply

    February 17, 2017 at 12:39 AM

    Thanks.. really useful

  • Mohamed
    · Reply

    June 20, 2017 at 10:16 AM

    Thanks a lot! really helpful 🙂

  • Greg
    · Reply

    November 29, 2017 at 11:20 AM

    We just upgraded from NAV 5.0 to 2017 cu6; we used to kill sessions from SQL but now that NAV has a middle tier server, we no longer can. This is the only workable solution I’ve found other than inactive time limits except that when I try to save it, I receive “You do not have permission to modify the ‘Session List’ Page.” I am in the SUPER group; this is NAV 2017 cu6. Any thoughts?
    Thanks!

    • Olof Simren
      · Reply

      Author
      December 5, 2017 at 9:00 AM

      Hi Greg,
      The error you get is because of your license, you need a developer license to do this change.

      /Olof

  • Vu, Dinh-Hung
    · Reply

    March 12, 2018 at 5:05 AM

    Hi Olof,

    I just created your Funktion “Kill session” in Page 9506, it is running very good, Thank You so much.

    Dinh-Hung Vu

  • SS
    · Reply

    November 1, 2018 at 11:50 PM

    I get the error Kill Session ? not defined as global variable y is that?

    • Rasmus
      · Reply

      April 8, 2019 at 4:22 AM

      Are you sure that you created your Page Action with name: “Kill Session” and the code inside the action as: “STOPSESSION(“Session ID”).

      Is is important to use “Session ID” and not SESSIONID in the STOPSESSION function, as the latter is a system function which will return the session ID of your own session and not the one selected in the list.

  • GS
    · Reply

    January 17, 2019 at 9:09 AM

    Hi Olaf,

    We use NAV 2017. We have a user who’s session will hang and he will close out of NAV using windows task manager. This leaves an open “ghost” session. We try and terminate it on the Sessions table but it won’t die and we have to restart the server. Any advice?
    Thanks!

    • Rasmus Engelbrecht
      · Reply

      April 8, 2019 at 4:28 AM

      You could try retrieving the session list from the PowerShell cmdlet “Get-NAVServerSession” in the NavAdminTool module.
      Then try removing the session with the “Remove-NavServerSesssion” cmdlet.

      But maybe the problem is that the session is so “busy” that the request for it to stop cannot be received by the session. This is unfortunate. You should look into what is cause the session to hang.

Leave a Reply

Your email is safe with us.
Cancel Reply

Subscribe to My Blog via Email

Check Out Our Apps in AppSource

My Dynamics NAV Partner

Naviona, LLC

Categories

  • Assembly (3)
  • Development (35)
  • Finance (14)
  • General (28)
  • Inventory (24)
  • Manufacturing (36)
  • Miscellaneous (27)
  • Purchase (9)
  • Sales (11)
  • Warehouse (7)

Tags

.net Add-in AI AppSource Assembly Assembly BOM Business Central CAL Capacity Consumption Contact Copilot Costs Customer Development Dimensions Excel Finance Flushing General Ledger Inventory Item Item Tracking Low-Level Code MRP NAV 2015 NAV 2016 Output Planning Production Production BOM Production Orders Purchase Orders Receipts Reporting Reports Routing Sales Sales Order Stockkeeping Unit Subcontracting Task List Warehouse Warehouse Shipment Work Center

Recent Posts

  • Business Central Configuration Audit using Vibe Coding
  • Copilot in Planning Parameter Worksheet
  • Copilot in Planning Worksheet
  • Copilot Inventory Queries
  • Record Deletion Tool for Business Central in AppSource
  • Reopen Finished Production Orders
  • XML Buffer and CSV Buffer Tables
  • Functionality Improvements in NAV 2017
  • Reversing Production Output and Consumption
  • Return Merchandise Authorization (RMA)

Categories

  • Assembly
  • Development
  • Finance
  • General
  • Inventory
  • Manufacturing
  • Miscellaneous
  • Purchase
  • Sales
  • Warehouse

Contact Us

We're currently offline. Send us an email and we'll get back to you, asap.

Send Message

Categories

  • Assembly (3)
  • Development (35)
  • Finance (14)
  • General (28)
  • Inventory (24)
  • Manufacturing (36)
  • Miscellaneous (27)
  • Purchase (9)
  • Sales (11)
  • Warehouse (7)

Tags

.net Add-in AI AppSource Assembly Assembly BOM Business Central CAL Capacity Consumption Contact Copilot Costs Customer Development Dimensions Excel Finance Flushing General Ledger Inventory Item Item Tracking Low-Level Code MRP NAV 2015 NAV 2016 Output Planning Production Production BOM Production Orders Purchase Orders Receipts Reporting Reports Routing Sales Sales Order Stockkeeping Unit Subcontracting Task List Warehouse Warehouse Shipment Work Center

Recent Posts

  • Business Central Configuration Audit using Vibe Coding
  • Copilot in Planning Parameter Worksheet
  • Copilot in Planning Worksheet
  • Copilot Inventory Queries
  • Record Deletion Tool for Business Central in AppSource
  • Reopen Finished Production Orders
  • XML Buffer and CSV Buffer Tables
  • Functionality Improvements in NAV 2017
  • Reversing Production Output and Consumption
  • Return Merchandise Authorization (RMA)

Recent Comments

  • Olof on Business Central Configuration Audit using Vibe Coding
  • Andrew Trayfoot on Business Central Configuration Audit using Vibe Coding
  • Barrett Allen on Reopen Finished Production Orders
  • Kateryna on Business Central Configuration Audit using Vibe Coding
  • Takeshi Setoya on Reopen Finished Production Orders
  • Steve on Consignment Inventory
  • Olof Simren on Copilot in Planning Worksheet
  • Omaer Amjad on Copilot in Planning Worksheet

© 2026 · Olof Simren

  • Home
  • About Me
  • Contact Me
  • Downloads
  • White Papers
  • Web Sites
  • Post List
  • Articles
  • FAQ
Prev Next