web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

database name and server name in c/al

(0) ShareShare
ReportReport
Posted on by 32,729

hi,

how can i get the current database name and server name in my c/al code?

br

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mohana Yadav Profile Picture
    61,017 Super User 2025 Season 2 on at

    try these posts

    http://www.dynamics.is/?p=541

    www.mibuso.com/.../viewtopic.php

  • keoma Profile Picture
    32,729 on at

    hi mohana,

    tables 2000000047 to get server and 2000000048 to get the Database name is the answer. thx.

    br

  • keoma Profile Picture
    32,729 on at

    hi,

    unfortunately does not work for nav 2013.

    it's done by the WSH (Windows Scripting Host).

    variables:

    - "wshNetworkInfo", Type: Automation, Subtype: 'Windows Script Host Object Model'.WshNetwork

    - "compName", Type: Text

    Code sample:

    CREATE(wshNetworkInfo);

    compName := wshNetworkInfo.ComputerName;

    CLEAR(wshNetworkInfo);

    properties of class WshNetwork:

    - UserDomain

    - UserName

    - UserProfile

    - ComputerName

    - Organization

    - Site

    for nav 5.0 function ENVIRON('COMPUTERNAME') works fine.

  • Community Member Profile Picture
    on at

    For Dynamics NAV and Al development you can use the Active Session tabel. See function GetDatabaseIndicatorText in table 79:

    ActiveSession.SETRANGE("Server Instance ID",SERVICEINSTANCEID);

    ActiveSession.SETRANGE("Session ID",SESSIONID);

    ActiveSession.FINDFIRST;

    Text := ActiveSession."Database Name" + ' - ' + ActiveSession."Server Computer Name";

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans