Section Access from SQL with Automatic Wildcard and Also Mimic'ing Access
This was based on a recent requirement to automate section access from a SQL database, but also allow some users to Mimic the access of others. I am not sure how helpful this is as I am sure it must have been covered before, but you never know!
What we will look at now is how you can create a system to mimic what other people can see, note because section access is applied in the document, users will still only be able to see their valid values. So if they choose someone with more values, it won’t matter. Our use case for this is that the users who are using this functionality are supersuers who can see all values.
Note at the end of the previous post we dropped the tmp table, remove this line of code if you want to use this mimic setup.
This is the code used in the Qlikview script:
//Do some funky magic to allow people to 'view as'
//Note this is controlled with field triggers on the MIMICNAME field which need to
//be updated if any more columns are controlled in the future
LOAD * INLINE [
//set a variable to loop over the number of control columns we have
let v_number_controls = FieldValueCount('controlcolumn');
//start the columns loop
for f=1 to $(v_number_controls)
//load the control data for our column
let v_access_column= FieldValue('controlcolumn',$(f));
LOAD NTNAME as MIMICNAME,subfield(ValidValues,',') as mimiccontrolcolumn_$(f);
SELECT UPPER(Username) as NTNAME, ValidValues
where dashboard ='$(v_filename)' and controlcolumn='$(v_access_column)';
//rename the control field to the correct fieldname
RENAME FIELD mimiccontrolcolumn_$(f) to '$(v_access_column)_mimic';
//loop into the next column we are controlling
drop table tmp;
//End that funky magic
o this is quite straight forward, we’ve just loaded our section access data and loaded the usernames into a column called MIMICNAME
So we can now create a list box based on this field, and then add the necessary field triggers to it.
For example in our live dashboard we have three fields which are controlled with section access, so I need to set up three triggers on the MIMICNAME column.
Firstly clear all three, then make the relevant selections: