Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
datanibbler
Champion
Champion

Visibility_condition for admins

Hi,

I have the requirement of putting into a variable an expression referring to a variable number of values:

- There are 2 QlikView_admins.

- For those 2 I have, in each app, a button governing a second variable v_Dev
=> This variable will turn on/off the visibility of several objects like rulers, comments etc. that are relevant for development, but not for

     the users.

I don't want to have these 2 names hard-coded in every app, but just once in a central file.

I have already tried with a Partial_reload_scenario, but that didn't work out.

So what I want to do now is the following:

- In the script, I will load that Excel_file with the names of all the QlikView_admins and generate the logons I need.

- I can create one variable for every line in that table - currently 2, but there might be more going forward.

=> The next step is where it fails: I want to create the entire statement for my visibility_condition based on those variables.

The code currently looks like this (I attach a sample xls that looks just like this, but in xls, not xlsx):

Developers_pre:
LOAD
Recno() as Line_ID_Admin,
Domain,
Name,
(
Upper(Domain) & '\' & Lower(Name)) as OSU
FROM
[\\rgb1app202\production\99_Resources\Wichtig_nicht_löschen\QlikView_Admins.xl*]
(
ooxml, embedded labels, table is Names);

//Jetzt gehen wir diese Tabelle Zeile für Zeile durch und generieren Variablen.
LET v_admins = NoOfRows('Developers_pre');
LET e_admins_only = '_';
FOR i = 1 TO $(v_admins)
LET varname = 'v_admin_' & $(i);
LET $(varname) = PEEK('OSU', ($(i)-1), Developers_pre);
LET e_admins_only = $(e_admins_only) & ' OR OSUSER() = ' & chr(39)&$(varname)&chr(39);
NEXT

This loop works in the first iteration, my variables look all right and that expression e_admins_only is properly constructed - in the first iteration. For some reason, it fails in the second one.

When you leave out that expression, it runs in 2 iterations.

Can anybody help me with that?

Thanks a lot!

Best regards,

DataNibbler

11 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

I think so. Nevertheless, here are a few magical tricks that may save your day. Continuing where you left off with the !-replacement, these statements show you how to avoid expansion, and provide a quote to the replace() function. My only hope is that this does the same thing in your version of QV Desktop as it does in mine:

SET vString = OSUSER() = !DISNEY\mickey.mouse!;

LET vResult = REPLACE(vString, '!', chr(39)); // Works like a charm

Good luck,

Peter

datanibbler
Champion
Champion
Author

A wonder 😉

I had tried the very same thing before - I have already noticed that those ASCII_functions can sometimes save your day - but to no avail. There must have been some typo somewhere.

now, however, it works.

Now I can have those two logons - hopefully more in the future - consolidated in one central file instead of hard-coding them everywhere and we won't have to reload the script, thereby losing all data that we don't have access to ourselves. That was the objective.

Thanks a lot!

Best regards,

DataNibbler