Options

Computer Name and/or IP Address

ta5ta5 Member Posts: 1,164
edited 2009-11-25 in NAV Tips & Tricks
Hi
How can I find out from a navision code unit on what computer (computer name, eg. xyws27) and/or its IP Address the code is currently running?
Thanks
Thomas

Comments

  • Options
    WaldoWaldo Member Posts: 3,412
    In the session table you have a field called "host name".
    You should filter on "My Session"=TRUE.

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    ta5ta5 Member Posts: 1,164
    Hi Waldo

    Thanks for your post.
    I have to problems:

    1) I cant find the field in my 3.7 installation, it seems to be a 4.x thing?
    2) On a test installation of 4.2 I see the field, but in host_name there is the name of the server, not of the client. ](*,)
  • Options
    WaldoWaldo Member Posts: 3,412
    I'm using SQL Server 4.00SP2 and all is correct.

    You're using 3.70 native?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    To find the computername you can also use
    'Windows Script Host Object Model'.IWshNetwork_Class
    

    as an automation control
  • Options
    WaldoWaldo Member Posts: 3,412
    Nice one, Mark.

    And it is automatically installed when Windows is installed ...

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    garakgarak Member Posts: 3,263
    Also possible

    Takes back the Computername where navision runs
    message(environ('computername'));

    Takes back the connected Client Computername from where is connect to an terminalserver (like citrix or MS Terminalserver)

    message(environ('Clientname'));

    Let us know, If you need the IP.

    Regards
    Do you make it right, it works too!
  • Options
    ta5ta5 Member Posts: 1,164
    Hi
    Thanx for your valuable help on this.
    I've tested both (WSH and environ), works like a charm =D>

    Thomas
  • Options
    WaldoWaldo Member Posts: 3,412
    garak wrote:
    Also possible

    Takes back the Computername where navision runs
    message(environ('computername'));

    Takes back the connected Client Computername from where is connect to an terminalserver (like citrix or MS Terminalserver)

    message(environ('Clientname'));

    Let us know, If you need the IP.

    Regards

    OK, how about the IP? :wink:

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    garakgarak Member Posts: 3,263
    Ok, here the code for the ip.
    1. create an singleinstance CU with variables to save the ip in an globel variable. Run this CU from CU 1 Company open (or your created cu). The reason for singleinst. CU is, an DOS Promp comes and users doesn't like it, ever see this promt
    
    needed variables 
    
    Name	DataType	Subtype	Length
    WSHShell	Automation	'Windows Script Host Object Model'.WshShell	
    WSHExec	Automation	'Windows Script Host Object Model'.IWshExec	
    WSHTxt	Automation	'Windows Script Host Object Model'.TextStream	
    FullCompName	Text		80
    FullCompIP	Text		80
    
    
    IF ISCLEAR(WSHShell) THEN
      CREATE(WSHShell);
    
    WSHExec := WSHShell.Exec('nslookup ' + ENVIRON('computername'));
    
    WSHTxt := WSHExec.StdOut;
    WSHTxt.SkipLine;
    WSHTxt.SkipLine;
    WSHTxt.SkipLine;
    FullCompName := COPYSTR(WSHTxt.ReadLine,1,80);
    FullCompIP := COPYSTR(WSHTxt.ReadLine,1,80);
    MESSAGE();
    CLEAR(WSHShell);
    
    MESSAGE(FullCompName);
    MESSAGE(FullCompIP);
    

    Regards
    Do you make it right, it works too!
  • Options
    krikikriki Member, Moderator Posts: 9,096
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    vikram7_dabasvikram7_dabas Member Posts: 611
    Dear Concern
    I want to know that where I have to write the following code in Navision codeunit,and following code only shows us the that client computer name not of others:

    message(environ('computername'));
    Vikram Dabas
    Navision Technical Consultant
  • Options
    garakgarak Member Posts: 3,263
    Sorry, i doesn't understand your problem.
    You want to know where you can write this codesnipes?
    Do you make it right, it works too!
  • Options
    vikram7_dabasvikram7_dabas Member Posts: 611
    Dear Concern
    I want to know that where I have to write following code:

    message(environ('computername'));

    It means that in which codeunit I have to write above code.Suppose I m using Native DB (Local) and write code code in CU 1 in Function CompanyOpen, when I open any company then it shows me a message(means, Computer Name).And If I m using Navision SQL server then where I have to write code and how this code will be executed?
    Vikram Dabas
    Navision Technical Consultant
  • Options
    Okune_JROkune_JR Member Posts: 3
    Hey I want to pull a report that will pull the computer name of the user how can I get this?
  • Options
    irasoelbaksirasoelbaks Member Posts: 119
    Please check the Active Session table as this should hold the computer name of the user:
    od5511ltzmf0.png
  • Options
    irasoelbaksirasoelbaks Member Posts: 119
    Please check the Active Session table as this should hold the computer name of the user:
    od5511ltzmf0.png
Sign In or Register to comment.