Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
AndyChappell
Contributor
Contributor

doreload() cause error when called after variable.setStringValue()

Hi,

I've been trying to work out why calls to qlik.app.doReload() this code works and calls to qlik.app.variable.setStringValue() also work but if the doReload is called after the setStringValue then an error is generated by the doReload

 

qlik.currApp(this).variable.setStringValue("LoadType","Catalogue").then
{
   alert("ReLoad");
    qlik.currApp(this).doReload();
}

 

This generates an error from an uncaught promise

enigma.6097683.js:9 Uncaught (in promise) Error: Reload in progress at e.Ue (enigma.6097683.js:9) at c (angular.f3474da.js:9) at angular.f3474da.js:9 at h.$digest (angular.f3474da.js:9) at h.$apply (angular.f3474da.js:9) at Object.f [as $apply] (qvangular.38ae0bf.js:9) at setup-view.800e26a.js:9
 Ue@enigma.6097683.js:9
 c@angular.f3474da.js:9
 (anonymous)@angular.f3474da.js:9
 $digest@angular.f3474da.js:9
 $apply@angular.f3474da.js:9
 f@qvangular.38ae0bf.js:9
 (anonymous)@setup-view.800e26a.js:9
 Promise.then (async)  
 pp@setup-view.800e26a.js:9
 o@setup-view.800e26a.js:9
 (anonymous)@setup-view.800e26a.js:9
 (anonymous)@setup-view.800e26a.js:9
 t@setup-view.800e26a.js:9
 (anonymous)@responsive-state.38d08ccf2bc5ad9f9.js:9
 e@responsive-state.38d08ccf2bc5ad9f9.js:9
 e@setup-view.800e26a.js:9
 (anonymous)@setup-view.800e26a.js:9
 t.emit@enigma.6097683.js:9
 e@enigma.6097683.js:9
 (anonymous)@enigma.6097683.js:9
 e@enigma.6097683.js:9
 t.emit@enigma.6097683.js:9
 e@enigma.6097683.js:9

 

The desired behavior is to set a variable and then trigger a reload

2 Replies
ErikWetterberg

Hi,

There is actually an error message in there:

Error: Reload in progress

 

Try catching errors from doReload() and handle them. 

 

There are also other ways to run a reload, I have written on those in a couple of posts:

https://extendingqlik.upper88.com/run-a-reload-from-a-qlik-sense-mashup/

https://extendingqlik.upper88.com/a-third-way-to-run-a-reload-from-a-qlik-sense-mashup/

Though I don't know if any of these would work in your scenario.

AndyChappell
Contributor
Contributor
Author

Hi,

Thanks, I cannot figure out how to apply the 2 mashup methods in my scenario.

What I'm trying to achieve is to load a data catalogue, allow the user to select certain items and then click a button to load the files in the selected catalogue items.  I'm able to pass the selected items to the load script via variables.  This works but I have to have 2 separate buttons at the moment one to set the variables and a separate one to trigger the reload.

When I put code in to catch the errors it is interesting that the error occurs after successful execution of the reload.  ie in the code below the alert "Finished" is seen before the error occurs triggering an automatic reload.

app.variable.setStringValue("LoadType","Catalogue").then(function success(b) {
   app.doReload().then(function success(a) {
        app.doSave();
        alert("Finsihed");
   }, function reject(a) {
       alert("Re-Load Failed");
   });
}, function fail(b) {
    alert("Set Variable Failed");
});

by accident I found that clicking the button when the sheet is in edit mode the code is successfully executed and no error is generated with all subsequent executions when the sheet is not in edit mode also being successful.

Reload the app and the error returns