Mimicing Section Access

This is a follow-on from my previous post on loading section access from SQL

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 usecase 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
//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
	from qlikview.qlikviewsectionaccess
	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	
next f;
drop table tmp;	
//End that funky magic

So 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:


The code used to make the selection is simply:

='("'&Concat(Distinct ManagingDirector_mimic&'"|"')&'")'


Leave a Reply