Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

QvxSDK, how to pass state in QvConnection (MParameters is null)

Hi,

I am creating a custom connector for QlikSense.

I have a problem with passing state (username, password) in QvConnection.

I can see state in connectiondialog.js/connectiondialog.ng.html as I read that like here:

string username, password;

  1. connection.MParameters.TryGetValue("userid", out username);
  2. connection.MParameters.TryGetValue("password", out password);

and it works when I have that first connectiondialog. However, I MParameters is null when I open the second build-in popup window in QlikSense for selecting tables/db/owner etc.

When that window is opened I don’t have any possibility to keep the state about username and password.

MParameters in QvConnection is null.

Do you know how can I use MParameters to get the information about username and password when I open QS build-in dialog for selecting data (database/owner/tables etc.)?

Can I use args from main entry point to pass some values somehow? Is there any way to use args in streaming mode with my customized params or username and password?

Your help will be be very appreciated.

4 Replies
Not applicable
Author

Hi Adam,

Once you build your connection string are you creating it against the app? It could be that the connection string has not been saved or not been setup correctly.

If you use the createNewConnection() method (example below) it should use the parameters in both your QvxConnection.cs and QvxServer.cs files so when using the sendJsonRequest method, as an example, or reloading, MParameters should be populated.

input.serverside.createNewConnection( $scope.name, $scope.connectionString, $scope.username,$scope.password);

where $scope.connectionString should look something like this -

"CUSTOM CONNECT TO \"provider=QlikViewExpressorConnector.exe; myCustomParam="myParam";\""

I hope that helps.


Thanks


Nick

Not applicable
Author

Hi nwr,

Thanks for your help, but I think the problem is not related to the configuration of connection.

I am setting up the connection string as it was done in QvxSDK_2.1x64 examples. It means, I use just standard code in connectdialog.js

I checked the workflow in debug mode very carefully and it works like that:

When I open my custom connector I am seeing connectdialog.ng.html window for typing credentials. At that stage everything is fine. When I press “Create a new connection” (onOKClicked()) button I can see that MParameters is populated in my QvXXXConnection, which is fine.

However, at the moment of clicking “Select Data” MParameters is null in

public override void Init()   method but populated in HandleJsonRequest

The second method:

public override string HandleJsonRequest(string method, string[] userParameters, QvxConnection connection)

is called later and then I have MParameters but it is too late because I don’t have information about state to initialize connection and set up MTables

I am able to provide more details if requested, but I think, it is impossible for now to use state in Init method for QvXXXConnection : QvConnection class

Summary:

MParameters is null in Init method but populated in HandleJsonRequest at later stage.

Do you know if there is any way to read the state in Init?

Your help would be much appreciated.

Not applicable
Author

Hi Adam,

I believe the behaviour you describe is 'working as designed' so to speak. The MParameters info is only available within the QvxConnection class when reloading as far as I know. When setting up the connection and selecting data I tend to push everything to the HandleJsonRequest method, the only downside being that there is no persistence in the connection. By that I mean you can't connect to a source in your QvxServer.cs and keep that connection open and reuse it. With each HandleJsonRequest you'll need to reconnect.

I hope that helps.

Thanks

Nick

Not applicable
Author

Hi Nick,

thanks for your reply. It works.

As you said. I built everything in HandleJsonRequest method + additional creation of MTables during Initializing QvConnection when Load Button is pressed (only when MParameters are not null).

Cheers,

Adam