Today I thought I would share how I used the system functions OSUser() and DocumentName() in a Qlik Sense app.  Here is some background on the app - the app resides on a server and users must log in to access it.  Users can have multiple copies of the app and each file name is unique.  The app allows users to store the results of their analysis in QVDs and I wanted the QVDs to include the QVF name/id as well as the logged in user name to ensure that there is one set of QVDs per app.  To do this, I used the OSUser() and DocumentName() functions.


Let’s learn a little more about these functions.  According to Qlik Sense Help, OSUser() returns the name of the user currently connected and DocumentName() returns the name of the current Qlik Sense app.  In the script below, I created variables that store the results of these functions.

script.png

OSUser() returns a string formatted like this:

UserDirectory=xxx;UserId=xxx

 

This is what I stored in the vFullUser variable.  Then in the vUser variable, I used the Right, Len and Index functions to capture just the UserId portion of the string.  DocumentName() returns the app ID for the QVF.  I use the vUser and vAppName variables later in the script when I am storing the data into QVDs.  Below is an example of what that script looks like.  I append the user ID and the app ID to the name of the QVD.

store.png

Qlik Sense offers many system functions that can be used in both the script and chart expressions to provide system, device and Qlik Sense app properties.  Here is a list of the available system functions:

 

AuthorDocumentTitleIsPartialReload
ClientPlatformEngineVersionOSUser
ComputerNameGetCollationLocaleProductVersion
DocumentNameGetObjectFieldReloadTime
DocumentPathGetRegistryStringStateName

 

You can learn more about the system functions available in Qlik Sense Help.  The OSUser() and DocumentName() functions are easy to use and capture the information I need to make the QVDs specific to a user and an app.  Keep these functions in mind the next time you need information about a Qlik Sense app or the system/device it is running on.

 

Thanks,

Jennell