Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nhoover
Luminary
Luminary

display the USER.EMAIL in App

Is there a way to populate the USER.EMAIL in the App on Qlik Cloud? So when a user accesses the app it will show a greeting? Welcome nhoover@ABC.com

Thanks all!

Labels (3)
1 Solution

Accepted Solutions
Levi_Turner
Employee
Employee

As @cristianj23a  referenced, the simple method is to use the OSUser() function but this does only display the user's subject in Qlik Cloud:

Levi_Turner_0-1691085002301.png

(Using Qlik ID thus no meaningful subject)

Levi_Turner_1-1691085063621.png

(using a custom IDP where we have crafted a meaningful subject)

But in many circumstances, this isn't a meaningful value so there are use cases where the user's email is preferrable. For this use case you can use the Advanced Analytics connector in the app like so:

  • Connector: Advanced Analytics
    • URL: https://{{your_tenant}}/api/v1/users
    • Method: GET
    • Query Parameters:
      • Name: filter
      • Value: (subject co "{{your user's subject}}")
        • May need to use the OSUser() function to figure this out
    • Authorization Method: Bearer Token
    • Response table:
      • Name of returned table: data
      • Table Path (JMESPath): data
    • Response Table
      • Table fields (JMESPath):
        • Name: email
        • Value: email
  • Variable:
    • Name: vUserSub
    • Definition: =If(Len(TextBetween(OSUser(),'UserDirectory=',';'))>0,TextBetween(OSUser(),'UserDirectory=',';') & '\\\\') & TextBetween(OSUser(),'UserId=',Null())
  • KPI Object:
    • 'Hello ' &
      endpoints.ScriptEvalStr('{"RequestType":"endpoint", "endpoint":{"connectionname":":{{name of your data connection}}", "parameters": {"request.parameters.filter" :"(subject co \"$(vUserSub)\")"}}}')
      & '!'

The resulting KPI object will look like this:

Levi_Turner_2-1691086199989.png

 

 

View solution in original post

8 Replies
cristianj23a
Partner - Creator III
Partner - Creator III

In Qlik Sense Cloud, you can use a feature called "Session Variables" to display the user's email or any other information in the app. Session Variables allow you to store and access data specific to each user's session within the app.

To display the user's email in the app as a greeting, follow these steps:

  1. Open your Qlik Sense app in the Qlik Sense Cloud.

  2. Go to "Data load editor" (or "Edit Script" in older versions of Qlik Sense).

  3. At the end of the script, add the following code to store the user's email in a session variable:

 

SET vEmail = OSUser();

 

The OSUser() function retrieves the email of the currently logged-in user.

Save and reload the data to make the variable available for use in the app.

Now, in the app, you can add a text object or a text box to display the greeting. Edit the text object properties and use the following expression to show the greeting message:

 

='Welcome ' & '$(vEmail)'

 

This expression concatenates the static text "Welcome " with the value stored in the session variable vEmail, which holds the user's email address.

Save the changes to the app.
Now, when a user accesses the app on Qlik Cloud, the greeting message will dynamically show their email address.

Please note that the OSUser() function is only available in certain editions of Qlik Sense, such as Qlik Sense Enterprise and Qlik Cloud Business. If you are using Qlik Sense Desktop or other editions, you may need to explore alternative methods to get the user's email address, such as using a login extension or integrating with an identity provider.

 

regarts.

https://www.linkedin.com/in/cristianjorge/
Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.
Levi_Turner
Employee
Employee

As @cristianj23a  referenced, the simple method is to use the OSUser() function but this does only display the user's subject in Qlik Cloud:

Levi_Turner_0-1691085002301.png

(Using Qlik ID thus no meaningful subject)

Levi_Turner_1-1691085063621.png

(using a custom IDP where we have crafted a meaningful subject)

But in many circumstances, this isn't a meaningful value so there are use cases where the user's email is preferrable. For this use case you can use the Advanced Analytics connector in the app like so:

  • Connector: Advanced Analytics
    • URL: https://{{your_tenant}}/api/v1/users
    • Method: GET
    • Query Parameters:
      • Name: filter
      • Value: (subject co "{{your user's subject}}")
        • May need to use the OSUser() function to figure this out
    • Authorization Method: Bearer Token
    • Response table:
      • Name of returned table: data
      • Table Path (JMESPath): data
    • Response Table
      • Table fields (JMESPath):
        • Name: email
        • Value: email
  • Variable:
    • Name: vUserSub
    • Definition: =If(Len(TextBetween(OSUser(),'UserDirectory=',';'))>0,TextBetween(OSUser(),'UserDirectory=',';') & '\\\\') & TextBetween(OSUser(),'UserId=',Null())
  • KPI Object:
    • 'Hello ' &
      endpoints.ScriptEvalStr('{"RequestType":"endpoint", "endpoint":{"connectionname":":{{name of your data connection}}", "parameters": {"request.parameters.filter" :"(subject co \"$(vUserSub)\")"}}}')
      & '!'

The resulting KPI object will look like this:

Levi_Turner_2-1691086199989.png

 

 

nhoover
Luminary
Luminary
Author

Thanks for the response and detailed instructions! This doesn't seem to work as I expected with how our tenant is setup. Example below.

nhoover_0-1691086987327.png

 

nhoover
Luminary
Luminary
Author

Thanks Levi, very detailed response and looks just like what I need to figure out my problem. Thanks for pointing me in the direction to master this issue.

nhoover
Luminary
Luminary
Author

For some reason, I don't have access to this connection in the data load editor...I'm following up with support. Thanks Again all!

nhoover_0-1691097125511.png

 

Levi_Turner
Employee
Employee

Hmm, it may be that your tenant does not have the machine learning endpoints enabled:

Levi_Turner_0-1691098512635.png

 

nhoover
Luminary
Luminary
Author

Bingo I toggled the setting on, and am not exploring the new Connection option. Thanks Levi!

kjun0306
Contributor III
Contributor III

I am getting an error: "Error in expression: ')' expected"