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

Hide error and div when user is not allowed to see object

Hello everyone,

i have an issue with my mashup and don't know how to handle it. Maybe someone can help me?

The mashup contains objects from 2 different apps. User A is allowed to see all objects while user B should only see some objects from one app. When i open the mashup with user B, error 403 is popping up and displays "forbidden". Even so i can browse through the website with that user.

First of all I dont want that error to be displayed. How can I do that?

Futhermore is it possible to hide the empty divs with for user B? Otherwise the page looks realy awkward with only some of the objects.

thanks in advance for your help!

4 Replies
ErikWetterberg

Hi,

You probably need to get the list of apps available to the user at startup. If the user has no access to an app, hide (or remove) the divs from the HTML page, otherwise open the app and get the objects.

Hope this helps

Erik Wetterberg

ErikWetterberg

Another option (assuming that it's the openApp that causes the error) could be to surround the openApp call with a javascript try/catch block. If you end up in the catch, it's time to hide the divs. Never tried this though, so I'm not sure it actually works. Would be easy for you to try,though.

Erik Wetterberg

valle
Partner - Contributor
Partner - Contributor
Author

Hi Erik,

thanks for your help, but unfortunately i am not very skilled with JS. Maybe you can provide me some code?

You're right, the error is caused by openApp.

ErikWetterberg

Hi,

Documentation for try/catch is here: try...catch - JavaScript | MDN

It would be something like this:

var app;

try {

   app = qlik.openApp("XXXXXXX",config);

   // if we are here, the user has access, so go on and get the objects

   app.getObject("QV01","zzzzzz");

   app.getObject("QV02","yyyyyyy");

} catch (e){

  //log error, can be removed when we've verified that it works

  console.log("openApp error",e);

  //hide elements

  $("#QV01").hide();

  $("#QV02").hide();

}

Still haven't tested, so I don't really know if it works.. Please let us know if it does, might be useful for others.

Erik Wetterberg