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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro To Assign MultiBox Value To Variable

I am trying to assign the MultiBox selection of a field to a variable (the user selected field value in the list should be assigned to a varaible for later calculations).

After seraching around, I created 2 empty varaibles in the load script as well as the following macro (sheet object trigger)

     Sub Set_Product_Value

         Set ProductTemp = ActiveDocument.Variables("Product_Temp")

         Set ProductValue = ActiveDocument.Variables("Product_Value")

         Set ProductTemp = ActiveDocument.Fields("Product").GetSelectedValues

         ProductValue.SetContent ProductTemp ,true

     End Sub

However I get the following error: Type mismatch: 'ProductValue.SetContent'

I am trying to have the value assigned to the variable 'Product_Value' in the document.

What is wrong ?

Thanks

1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Simply you can use as

ProductTemp = ActiveDocument.Evaluate("GetFieldSelections(Product)")

View solution in original post

3 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi

GetSelectedValues is a list (can say as array) of values. you cannot assign it to a QV variable.

You need to use

activedocument.Evaluate("GetFieldSelections(Product, ',', 99)")

Hope it helps

Not applicable
Author

Thank you for the quick answer.

I updated the concerned line with:    

     Set ProductTemp = ActiveDocument.Evaluate([string:"GetFieldSelections(Product)"])

Only one value is possible, so I omitted the extra varaibles in the GetFieldSelections function.

As you can see I also added [string: "-"], as I get an error message.

The items in the 'Product' list are effectively multi-word.

How would I assign this acorrectly in the macro ?

CELAMBARASAN
Partner - Champion
Partner - Champion

Simply you can use as

ProductTemp = ActiveDocument.Evaluate("GetFieldSelections(Product)")