Dynamics NAV Integration

Tag: environment variables

Determining your session environment in Dynamics NAV – Citrix vs. local

by admin on nov.28, 2009, under Code

Today I ran into a scenario where I wanted some specific code to be run when the client was started on a Citrix server and some other code to be run when the client was started on a desktop.

To determine where the client is started, we can use an automation of the subtybe Windows Scipting Host Object Model to access the Windows Environment variables.
Those of you that were around ind the good old DOS  days surely know a great deal about the environment variables. We are interested in the environment variable called SESSIONNAME, which on Citrix has a value something like “ICA……..” and locally has the value “CONSOLE”.

So by requesting the content of SESSIONNAME we can determine if the client is being executed on the Citrix server.

Here’s how:

1. Create an automation variable, with the subtype: ‘Windows Script Host Object Model’.WshShell

Automations in Dynamics NAVWSHShell

And the code:

IF ISCLEAR(WSHShell) THEN
CREATE(WSHShell);
WSHShell.ExpandEnvironmentStrings(BSTR Src)
CLEAR(WSHShell);

code

Notice that we have to name the environment variable by using the prefix and suffix percent character (%).

Of course this is useful for many other things to, if you want to know something about the current client session.

You can get a full list of environment variables by opening a command prompt and typing

“set”

A lot of useful information exists in the environment variables. For example the name of the Program Files folder etc.

Kommentarer slået fra :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!