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

Engine API select range in .NET application

Hi All,

I apologise if this sounds like a stupid question but how do I use the Qlik Engine API in a .NET application? The reason I ask is because I want to select based on a range instead of an absolute value. E.g. select all transactions where, 500 <= amount <= 10,000, or where name like "sm%".

In order to try this out I created .NET WPF app where I display a Qlik Sheet using a <WebBrowser> control and that works fine. I honestly have no idea what to do next, I looked at the examples and got nowhere fast. I'm using the Helpdesk Management app as my test app. I'm also using the sheet Performance to do my select range testing. Hopefully the pic below will better explain what I'm trying to do. Basically I wan't to use Qlik Engine to filter selections where the Open Cases value is > 20 but < 80.

2016-06-07 14_06_15-Qlik Sense.png

Regards,

Alex

1 Solution

Accepted Solutions
Employee
Employee

Re: Engine API select range in .NET application

The general selection and data retrieval mechanism of Qlik Sense is based on the concepts of hypercubes‌ and list objects‌. You might want to read a little about those to get an understand for how they work. However, for the case where you want to select all case owners based on a pattern matching on the values of the field, you probably want to use selection methods found in the class Field‌. Then once you have performed the selection, you can use the class IExtendedCurrentSelection to retrieve a list of the values that were selected.

The code for your example would look something like this (where "theApp" is the "Helpdesk Management" app in your example):

var fieldOfInterest = "Case Owner";


// Select the relevant values of the field

var theField = theApp.GetField(fieldOfInterest);

theField.Select("A*");


// Get the set of field values that were selected

var currentSelection = theApp.GetExtendedCurrentSelection();

var largePage = new NxPage { Top = 0, Left = 0, Width = 10, Height = 100 };

var pages = currentSelection.GetSelectedData(fieldOfInterest, new [] { largePage });

var selectedValues = pages.SelectMany(p => p.Matrix.Select(r => r[0].Text));

16 Replies
konrad_mattheis
Contributor III

Re: Engine API select range in .NET application

Hi Alex,

the text is a little bit confusing for me. The .NET SDK has nothing todo with a Webbrowsercontrol.

If you like to use the .NET SDK you can create a GenericSessionObject as Listbox make than a

currentSessionListBox.SearchForAsync("500 <= amount <= 10,000)

and than a AcceptSearchAsync(true).

bye Konrad

Not applicable

Re: Engine API select range in .NET application

Thank you for your response.I will do my best to simplify. I have a .NET application, how do I then call the Qlik Engine API. Say for example I wanted to run the following:

{ "jsonrpc": "2.0", "id": 7, "method": "ClearAll", "handle": 1, "params": [] }


I would ultimately like to get familiar with the Qlik Engine API, if I can get the ClearAll call working, I can go from there. Again if this is confusing, I'm sorry, I'm very new to Qlik Development.

konrad_mattheis
Contributor III

Re: Engine API select range in .NET application

Hi Alex,

you can use for example ClearAll also on the app object.

http://help.qlik.com/en-US/sense-developer/2.2/Subsystems/APIs/Content/MashupAPI/Methods/clearAll-me...

bye Konrad

Not applicable

Re: Engine API select range in .NET application

Hi Konrad,

Thanks, I am aware of that method. I used the ClearAll only as an example. I wanted to generate a script which could then be passed to Qlik Engine in a .NET application.

Clearly I don't know enough about Qlik to be asking the right question, so I can going to consider this question closed but unanswered. Again thank you for taking the time to respond.

Alex

Not applicable

Re: Engine API select range in .NET application

Hi,

If you don't want to use the .Net SDK Api but instead use the Engine API you can use SendAsync.
Example:

var serverAddress = "http://server.domian.com";

var qlikSenseServer = Qlik.Engine.Location.FromUri(new Uri(serverAddress));

var appId = qlikSenseServer.AppWithNameOrDefault("AppName", noVersionCheck: true);

qlikSenseServer.AsNtlmUserViaProxy();

var task = await qlikSenseServer.App(appId, noVersionCheck: true).Session.SendAsync("your json");


Best Regards
Lars-Göran Book

konrad_mattheis
Contributor III

Re: Engine API select range in .NET application

Hi Lars-Göran,

I found only the following signatures of the Function SendAsync() in the Interface

Task SendAsync(Request request);

Task<T> SendAsync<T>(Request request, Func<Response, T> continueWith);

Task<Response> SendAsync(int wsHandle, string wsMethod, IEnumerable<string> argumentNames, params object[] arguments);

Please can you give an examaple to one of them.

bye Konrad

Not applicable

Re: Engine API select range in .NET application

I couldn't figure out who to send JSON but I found this works, I'm using Qlik Sense Desktop though:

var qlikLocation = Location.FromUri(new Uri("ws://127.0.0.1:4848"));

qlikLocation.AsDirectConnectionToPersonalEdition();

IAppIdentifier helpdeskManagementAppId = qlikLoc.AppWithNameOrDefault("Helpdesk Management");

var qlikRequest = new Qlik.Engine.Communication.IO.Request(1, "ClearAll");

await qlikLocation.App(helpdeskManagementAppId, noVersionCheck: true).Session.SendAsync(qlikRequest);

Employee
Employee

Re: Engine API select range in .NET application

Hi! You might want to check out the following page that provides information for getting started with the .Net SDK:

http://help.qlik.com/en-US/sense-developer/2.2/Subsystems/NetSDKAPI/Content/GettingStarted/Net-Sdk-G...

You can also find a couple of examples on how to use it here:

Download code samples ‒ Qlik Sense

You can check out the "Custom desktop" example if you want to see how to use the "ClearAll" operation from the SDK.

Employee
Employee

Re: Engine API select range in .NET application

The .Net SDK provides C# wrappers for the underlying Json RPC API. The .Net SDK basically translates the C# method calls into the json strings you need so that you don't have to worry about things like handles and request ids. Documentation for the particular method "ClearAll" can be found here:

IApp.ClearAll Method

There is also an asynchronous version here:

http://help.qlik.com/en-US/sense-developer/2.2/apis/net%20sdk/html/M_Qlik_Engine_IApp_ClearAllAsync_...

Community Browser