Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Not applicable

Remove all data from app using .NET SDK

Hi, I'm trying to remove all dataconnections, script and data from an app in Sense Desktop 1.1, so it can be used as a (small) template app that only contains visualizations. This template app can then be used to create a new app with its own dataconnection and load script.

Removing the dataconnections and script is no problem, but when I use the following method without arguments to remove the data (doesn't matter if I open the app with or without data)

Task Qlik.Engine.IApp.RemoveAllData(bool confirm = false, AsyncHandle asyncHandle = null);

I get this exception:

Qlik.Engine.MethodInvocationException occurred

  HResult=-2146233074

  Message=Internal error [LOCERR_INTERNAL_ERROR]:Internal error()

  Source=mscorlib

  StackTrace:

      at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

      at ...

I've tried the same method on Sense Server 1.1, but I get the same exception.


Then I tried to replace the load script by DROP TABLE; and use the following methods to reload the app with the updated script, but the data is not removed.

Task<bool> DoReloadAsync(int mode = 0, bool partial = false, bool debug = false, AsyncHandle asyncHandle = null);

However, when I manually reload the data, all data is removed as expected.

Is this a bug or am I using the wrong method?

Tags (1)
1 Solution

Accepted Solutions
Not applicable

Re: Remove all data from app using .NET SDK

Hi,

you could do this with the following code:

var originaScript = myApp.GetScript();

myApp.SetScript(myApp.GetEmptyScript());

myApp.DoReload();

myApp.DoSave();

myApp.SetScript(originalScript);

myApp.DoSave();

Best regards

Lars-Göran Book

4 Replies
Not applicable

Re: Remove all data from app using .NET SDK

Hi,

This method was not intended to be public and is only for internal use.

There are several ways to delete data within an app, to help you I need to know more about your use case.

Sorry for the inconvenience.

Best regards

Lars-Göran Book

Not applicable

Re: Remove all data from app using .NET SDK

Hi Lars-Goran, thanks for your answer.

I my case, I want to create a template App that only contains some basic visualizations. This template App is used to create new Apps 'on the fly'. New Apps get their own dataconnection and load script. The data model of all Apps is identical (only the dataconnection and database that's being queried is different), that's why I can use a single template App with visualizations in it.

So basically I'm creating an App design-time and want to remove everything from it, except for the visualizations (to keep it small and remove sensitive data and connectionstrings). The remaining App can then be used as a template to create new Apps run-time.

Danny.

Not applicable

Re: Remove all data from app using .NET SDK

Hi,

you could do this with the following code:

var originaScript = myApp.GetScript();

myApp.SetScript(myApp.GetEmptyScript());

myApp.DoReload();

myApp.DoSave();

myApp.SetScript(originalScript);

myApp.DoSave();

Best regards

Lars-Göran Book

Not applicable

Re: Remove all data from app using .NET SDK

Thanks.

I also know why the above code didn't work earlier. I opened the app without data (noData: true).

Community Browser