Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

VBscript - how to create a Generic list of type string

I need to create an Generic list of type String, that I want to fill with some values.

I tried the following statements

Dim sList
Set sList = CreateObject(“System.Collections.Generic.List[String]”)
sList.Add(“Read”)
sList.Add(“Stop”)

This is not working.

Can you please provide me with the correct code?

15 Replies
Not applicable
Author

Marcus,

When I use the string 'Read, Copy' (without ') as values for the valuelist in the call, I get the following (unfortunately in Dutch) error message from the call:

---------------------------

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode><faultstring xml:lang="nl-NL">Er is een uitzondering opgetreden in de formatter bij de poging het bericht Er is een fout opgetreden tijdens de poging parameter http://ws.qliktech.com/QMS/11/:variableValues te deserialiseren. Het InnerException-bericht is Fout in regel 1 positie 441. Status Element wordt verwacht.. Text met naam , naamruimte  is aangetroffen. . Zie InnerException voor meer details. te deserialiseren.</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>Fout in regel 1 positie 441. Status Element wordt verwacht.. Text met naam , naamruimte  is aangetroffen. </Message><Stack

---------------------------

It is telling that during deserialise/evaluation of the parameter variableValues a wrong format was expected. A status element was expected and instead a string was found. So the string Read, Copy is not the correct format for passing on a generic list of type string.

With use of QMS API client (one of the QV powertools) a can start the EDX job and pass on a correct value for the variableValues that also in that tool is shown as List(String) and where I have to input the values with a separate screen in which Index 0, Type String and Value is shown and there I give in Value Read for the first line and value Copy for the second line. Unfortunately I cannot see in this tool how this list is passed to the API.

The only thing I now is that is must be a generic list of type String (so no Array or just a String).

Not applicable
Author

Hi Marcus,

I get indeed an error in the QV VBscript editor telling me that it is not possible to use CreateObject() which required the use of ActiveX.


Is there a way to simulate the content of an generic list of type String? In any other format that i can create in the VB script? I only need to pass the first occurrence of this list.

marcus_sommer

I think with a ListOfStrings is an array meant, maybe something like this:

a = ActiveDocument.Variables("vCall1").getcontent.string

b = ActiveDocument.Variables("vCall2").getcontent.string

c = array(a, b)

- Marcus

Not applicable
Author

Marcus,

That's the big issue: a generic list of type String is not a normal Array. So this is not working.

Not applicable
Author

Searching further on the forum, gives me this piece of information:

This is not an object that's specifically a part of the API code - it's .NET behavior. You haven't defined that generic object lists should be of the type List<>, but Array[]. Array[] does not have .Add, but List<> does.

If you got to the Solution Explorer > (Project) > Services References > (QMS backend) > right click > Service Reference Settings.. > Collection type. Set this to "System.Collections.Generic.List" instead. You might need to re-build the solution for this (Ctrl+Shift+B).

You could as well use Array[] if you are more comfortable with that, but in my opinion it will only limit usage of API object lists, since List<> is a very powerful enumerable collection.

I found this information in the following post:

QVS API Support

So if I understood this information correctly, it looks like that you need to change a setting on the server to make working with generic lists possible. If this is true, can someone please tell me exactly what I need to change? And where i can find this setting?

marcus_sommer

I think that this meant, that's not possible to use vbs for this and that you need to use visual studio like described here: Using EDX in QlikView 11 - basic example.

- Marcus