Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

nihhalmca
Valued Contributor II

Environment Variable

Hi All,

I want to create a environment variable.

Actually we are doing development in test server then we move to prod sever.

Application has path like [\\100.10.0.10\Qlikview\Data\filename.xls] --------- in test server

Whenever I move to prod it will get failed due to path error, prod server (IP) name is different, path should be like this [\\1001.11.0.11\Qlikview\Data\filename.xls]'----- in prod server

So I created environment variable like as

LET vServerName = ComputerName();
IF ComputerName = 'Devservername' then
SET vEnv = '\\100.10.0.10';
else
SET vEnv = '\\1001.11.0.11';
ENDIF

However its not working, it execute always else condition (actually vEnv should contain \\100.10.0.10 but it contain \\1001.11.0.11.

There is any mistake in the code.

Could you please assist on this.

Thanks,

Nihhal.

1 Solution

Accepted Solutions

Re: Environment Variable

May be put the variable within single quotes

LET vServerName = ComputerName();

IF '$(vServerName)' = 'Devservername' then

SET vEnv = '\\100.10.0.10';

else

SET vEnv = '\\1001.11.0.11';

ENDIF

View solution in original post

10 Replies

Re: Environment Variable

You meant this?

LET vServerName = ComputerName();
IF $(vServerName) = 'Devservername' then
SET vEnv = '\\100.10.0.10';
else
SET vEnv = '\\1001.11.0.11';
ENDIF

Re: Environment Variable

try like this

IF ComputerName() = 'Devservername' then

nihhalmca
Valued Contributor II

Re: Environment Variable

Yes Sunny, even not working.

Re: Environment Variable

May be put the variable within single quotes

LET vServerName = ComputerName();

IF '$(vServerName)' = 'Devservername' then

SET vEnv = '\\100.10.0.10';

else

SET vEnv = '\\1001.11.0.11';

ENDIF

View solution in original post

nihhalmca
Valued Contributor II

Re: Environment Variable

Thanks sunny.

this one also helpful.

LET vServerName = ComputerName();

IF ComuterName() = '$(vServerName)' then

SET vEnv = '\\100.10.0.10';

else

SET vEnv = '\\1001.11.0.11';

ENDIF

Re: Environment Variable

This IF statement will always be true my friend Because your variable is also ComputerName()... Did you mean this

LET vServerName = 'Devservername';

IF ComuterName() = '$(vServerName)' then

SET vEnv = '\\100.10.0.10';

else

SET vEnv = '\\1001.11.0.11';

ENDIF

Highlighted
nihhalmca
Valued Contributor II

Re: Environment Variable

Just I missed () sunnay as Avinash said.

working this without vServername variable

//LET vServerName = ComputerName(); -- not required
IF ComputerName() = 'Devservername' then
SET vEnv = '\\100.10.0.10';
else
SET vEnv = '\\1001.11.0.11';
ENDIF

Re: Environment Variable

Hahahaha yes, I guess I thought that you wanted to do this in two steps where you first assign the value of ComputerName() to a variable and then use that... but yes, it can be done in a single step also....

nihhalmca
Valued Contributor II

Re: Environment Variable

Hi Sunny,

After all my practice.

If I go without storing servername in a variable (single step), it works wired (first time it works fine after that it works as unexpected.

Best practice is storing server name into variable (two steps).

LET vServerName = ComputerName();
IF ComputerName() = 'servername'