Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
korsikov
Partner - Specialist III
Partner - Specialist III

Issue with String to List Conversion in Qlik Cloud Automation


Hello Qlik Community,

I'm working on an automation in Qlik Cloud and encountered a problem when converting a string to a list. Here’s the situation:

Problem Description:

I have a string that looks like this: Item1, Item2, Item3

I assign it to a variable using the following operation: { "Operation": "Set ItemsSTR equal to Item1, Item2, Item3" }

Then, I try to convert this string to a list: { "Operation": "Add <list> to ItemsList" }

However, the resulting list structure looks like this:

[ [ "Item1", "Item2", "Item3" ] ]

When I use a Loop block to iterate over this list, it only processes the first element (Item1).

Alternative Approach:

If I add each item individually, like this:

{ "Operation": "Add Item1 to ItemsList" }

{ "Operation": "Add Item2 to ItemsList" }

{ "Operation": "Add Item3 to ItemsList" }

The resulting list is correctly formatted as:

[ "Item1", "Item2", "Item3" ]

In this case, the Loop block iterates over each item correctly.

Output from Automation:

String "Item1, Item2, Item3" convert to List and run in LOOP

Item ListArray
Item String Item1, Item2, Item3
++++++++++++++++

Output in Loop>Item : Array

  •  

Add items "Item1, Item2, Item3" to List and run in LOOP

Item List Array
++++++++++

Output in Loop>Item : Item1

Output in Loop>Item : Item2

Output in Loop>Item : Item3

Question:

Why does the List operation convert the string differently when using "Add <list> to ItemsList"? How can I make the conversion work correctly without manually adding each item?

I would appreciate any advice or suggestions!
Thank you in advance!

Example automation in attach

Labels (1)
1 Solution

Accepted Solutions
korsikov
Partner - Specialist III
Partner - Specialist III
Author

 

  • Create a temporary variable of type String (e.g., ItemsTempList).

  • Perform the following operation to set its value:

    { "Operation": "Set value of { ItemsTempList }", "value": "{explode: {$.ItemsSTR}, ',', 100}" }

    This will convert your string into a list-like string.

  • Next, use a Loop block to iterate through ItemsTempList:

    • Inside the loop, add each element to the final list ItemsList using the "Add item" operation:
       
      { "Operation": "Add item to { ItemsList }", "value": "{ $.loop.item }" }

 

 

View solution in original post

1 Reply
korsikov
Partner - Specialist III
Partner - Specialist III
Author

 

  • Create a temporary variable of type String (e.g., ItemsTempList).

  • Perform the following operation to set its value:

    { "Operation": "Set value of { ItemsTempList }", "value": "{explode: {$.ItemsSTR}, ',', 100}" }

    This will convert your string into a list-like string.

  • Next, use a Loop block to iterate through ItemsTempList:

    • Inside the loop, add each element to the final list ItemsList using the "Add item" operation:
       
      { "Operation": "Add item to { ItemsList }", "value": "{ $.loop.item }" }