Categories
Macros and Automatisation QlikView /en Tips n Tricks /en

QlikView User Access and Object Access

Introduction

Security is one of the main topics and issues, deploying data to different users or group of users. Additional you have to seperate between data filters and object/feature visibilities. To achieve a individual “restriction” we split access rules into:

  • ObjectRights (What a user can “see”)
  • AccessRights (Which data a user can “browse”)

Scripts

Here you’ll find all scripts that are needed to implement the functionality.

Macros

Here you’ll find all VBA-Macros that are needed to use the functionality.

Loop Sheets

SUB LoopSheets

 REM ** loop through all sheets **
 REM @Author <Philipp@Frenzel.Net>
 REM beeye.org
 FOR i = 0 TO ActiveDocument.NoOfSheets - 1
     SET ss= ActiveDocument.GetSheet(i)
     varCompare = ss.GetProperties.Name 
     IF LEFT(varCompare,7) <> "Sandbox" THEN
      ReadObjectsAndSetRights varCompare
     END IF
 NEXT

 END SUB

Set Object Visibility

SUB ReadObjectsAndSetRights(SheetName)
 
 REM ** minimize all sheet objects on sheet Main **
 REM Rights by beeye.org
 REM Author Philipp Frenzel
 
 varVisibilityPrefix = "=if(only({<RightRule={'$(=OSUser())"
 varVisibilitySuffix = "'}>} RightAccess)=1,1,0)"
 
 SET s=ActiveDocument.Sheets(SheetName)
 FOR i=0 TO s.NoOfSheetObjects-1
     'the formula for our rights management
     varVisibility = varVisibilityPrefix & s.GetProperties.SheetId & s.SheetObjects(i).getObjectId & varVisibilitySuffix
     SET obj = ActiveDocument.GetSheetObject(s.SheetObjects(i).getObjectId)
     ' type 4 means Tablebox so there you can find the properties over the following context
     IF obj.getObjectType < 5 THEN
 SET objProp = obj.GetProperties
 SET objExpr = objProp.Layout.Frame.Show
 ' toggle invisible property of chart expression
 ' based on value of DEPT field selection
 objExpr.Expression.v = varVisibility
 'objExpr.Expression.v = 1 'uncomment this, if all should be visible
 objExpr.Always = false
 obj.SetProperties objProp
 END IF
 ' type 10 are Pivottables here we set the visibility under the layout tab
 IF (obj.getObjectType > 9 AND obj.getObjectType < 16) OR (obj.getObjectType > 19 AND obj.getObjectType < 24) THEN
 SET objProp = obj.GetProperties
 SET objExpr = objProp.GraphLayout.Frame.Show
 ' toggle invisible property of chart expression
 ' based on value of DEPT field selection
 objExpr.Expression.v = varVisibility
 objExpr.Always = false
 obj.SetProperties objProp
 END IF
 NEXT
 
 END SUB

 

Leave a Reply