Qlik Community

Qlik Connectors Discussions

Discussion Board for collaboration regarding Qlik Connectors.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

Custom Connector Troubles

Hi There,

Hoping someone here can help me out. I have been creating a custom connector based off of the "simple" example that's been provided by Qlik.

Most of it is done, I'm just getting hung up on one thing:

I can't pass data from my Server file to my Connection file. In other words, I have chosen a couple of items during the Selection screen that I need to access when I press the Load Data button, but I have no way of being able to do that from what I can tell.

The reason I need to do this is that the actual Loading of the data needs to be dynamic based on a couple of internal values that are found, not just the table name, as it's not really a table that I'm reaching out to.

Even if there's just a way within my C# code to access the text that's on the QlikView Editor, that'd allow me to get what I need from here. But right now, in the Connection file, during the Init() method, I cannot find any way to access any internal information about the connection that I'm using.

If someone can help, that would be awesome, or if anyone needs more information, I'll try to provide it.

Thanks,

Casey

Labels (3)
1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

The connection string is the communication between your connection edit dialog and the connector.  Any parameters you set in the edit dialog must be saved in the connection string as key=value pairs.  Those items will then be available in the Init() method via QvxConnection.MParameters. Init() will get called when a CONNECT statement is executed in the script.

During execution, each SELECT statement will be passed to the ExtractQuery() method. You can override this method and interrogate the SELECT statement to capture any specifics you need from the statement.

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

12 Replies
Highlighted
MVP & Luminary
MVP & Luminary

The connection string is the communication between your connection edit dialog and the connector.  Any parameters you set in the edit dialog must be saved in the connection string as key=value pairs.  Those items will then be available in the Init() method via QvxConnection.MParameters. Init() will get called when a CONNECT statement is executed in the script.

During execution, each SELECT statement will be passed to the ExtractQuery() method. You can override this method and interrogate the SELECT statement to capture any specifics you need from the statement.

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

Highlighted
Partner
Partner

Hi @rwunderlich 

Thank you for this. I will take a look at this and see if I can get it to work.

Casey

Highlighted
Contributor
Contributor

Hello. Sorry for jumping in. I've a question. You mention your custom connector is based on the simple example provided by Qlik. Which one do you mean? I'm making a custom connector and hang on the part where the json handler is called in the example. Do you have this item, if not, how do you communicate from the web files to a function in the c# files?

Highlighted
Partner
Partner

This is working great. While I'm not finished yet, I believe this will get me across the finish line. Thank you very much for your help @rwunderlich 

Highlighted
Partner
Partner

I spoke too soon @rwunderlich I tried to bypass the custom connection string thing and I think it might have kicked me in the butt.

Where I'm at: I'm loading tables/fields in the SelectDialog just fine. Connection created at this point.

When I have a table selected from the above, with x number of fields, and go to Load Data, I keep getting an error that the Table cannot be found.

I'm worried that even though the Query is coming through in ExtractQuery, that there's something missing that's preventing the Table from being found.

I hope that makes sense and you can still help me out.

Highlighted
MVP & Luminary
MVP & Luminary

Did you define the table and the fields in the Init() method? Or are you trying to define the table on the fly?

-Rob

Highlighted
Partner
Partner

@rwunderlich I landed in the middle. I want to define it on the fly inside the ExtractQuery method as that's where I have the info I need in order to do it. But in the end, I defined my MTables below, and then modified the Name and added fields. I did NOT define fields in the Init().

My Init():

MTables = new List<QvxTable>
{
     new QvxTable
     {
          TableName = "placeholder",
          GetRows = GetApplicationEvents,
      }
};

 

And then I did the below to translate the fields from the Query into a string list, and eventually into a QvxField List, and then finally into a QvxField Array.

List<string> fieldList = new List<string>();

fieldList = finalFields.Split(',').ToList();
var currentFieldsList = new List<QvxField>();

foreach (string field in fieldList)
{
     QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, "THE FIELD: " + field);
     currentFieldsList.Add(new QvxField(field, QvxFieldType.QVX_TEXT, QvxNullRepresentation.QVX_NULL_FLAG_SUPPRESS_DATA, FieldAttrType.ASCII));
}

QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Error, "mtablesname: " + MTables[0].TableName);
MTables[0].TableName = currentTable;
var currentFieldsArray = new QvxField[] { };
currentFieldsArray = currentFieldsList.ToArray();
MTables[0].Fields = currentFieldsArray;

 

I SOOOOO appreciate your help. I keep getting really close and then hit these new speed bumps as I learn this new concept.

- Casey

Highlighted
MVP & Luminary
MVP & Luminary

Are you returning a QvxDataTable from ExtractQuery()?

-Rob

Partner
Partner

Yes I am. And I think I might have figured out my issue. I'm trying to extract the Table name from the Query to finish setting up my MTables. However I think my string manipulation is simply wrong. I'm working on testing the theory as I'm typing this to see if it was just my mistake on extraction of the table name.

Will update.

Thanks,

Casey