Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I found the Connection and ConnectionInfo classes in the Qlik.Engine namespace, but how do I use them to retrieve
-The list of connections in an app
-The list of all connections
And how do I create a new custom connection in an app?
OK I figured out how to get the connections in an app.
Something like this:
IAppIdentifier selectedAppIdentifier = location.AppWithNameOrDefault(listBox1.SelectedItem.ToString());
IApp application = location.App(selectedAppIdentifier);
foreach (IConnection connectionInfo in application.GetConnections())
{
listBox2.Items.Add(connectionInfo.Name);
}
But I am still trying to figure out how to create new connections from scratch, and I don't mean just to add the connect statement in the script. I need to create actual custom connections with their stored properties...
You'll need to go through the Repository API to do that kind of operations. Have a look at this one:
Thanks. I may have to eventually use the repository API, but I would really prefer to solve this with the .Net SDK. Actually this finally did the trick for me with the .Net SDK:
IAppIdentifier selectedAppIdentifier = location.AppWithNameOrDefault(listBox1.SelectedItem.ToString());
IApp application = location.App(selectedAppIdentifier);
Connection connection = new Connection
{
Name = textBoxConnectionName.Text,
ConnectionString = textBoxConnectionString.Text,
Type = textBoxConnectionType.Text,
Password = textBoxPassword1.Text
};
application.CreateConnection(connection);
But I am only prototyping with Qlik Sense Desktop and will eventually need this to work in a server environment. Is there any reason why this wouldn't work in the Server? BTW the connections are of CUSTOM CONNECT type.
Nice! I wasn't aware of that method. One learns something new every day on Qlik Community 🙂
I can't see anything that suggests that it can't be used in a server environment, but then again, since the method is obviously new to me, perhaps someone else can chime in.