In Dynamics NAV applications I sometimes use the client host name to store settings or as a filter. Until now I have been using the ENVIRON function but it is not available in NAV 2009.
I have now solved this issue with the following function that will also work in Role Tailored Client.
[code]IF ISCLEAR(WShell) THEN
CREATE(WShell,TRUE,TRUE);
EnviormentPath := ‘PROCESS’;
WEnviroment := WShell.Environment(EnviormentPath);
IF UPPERCASE(WEnviroment.Item(‘SESSIONNAME’)) = ‘CONSOLE’ THEN
ComputerName := WEnviroment.Item(‘COMPUTERNAME’)
ELSE
ComputerName := WEnviroment.Item(‘CLIENTNAME’)[/code]
Where
Name | DataType | Subtype |
WShell | Automation | ‘Windows Script Host Object Model’.WshShell |
WEnviroment | Automation | ‘Windows Script Host Object Model’.WshEnvironment |
EnviormentPath | Code[10] |