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

How can I hardcode and store GetFieldSelections() in a variable?

Hi,

I have a field called ProductID. Say I select ProductID = { "5" , "6" }

I am trying to GetFieldSelections(ProductID) --> and store it in a variable (vProductSelection1) , but hardcoded.

So that when my selections change (i.e. values in GetFieldSelections(ProductID) would change too), my variable value stays the same.

e.g. if I now select ProductID = { "8" , "9" }, although GetFieldSelections(ProductID) now shows "8 , 9",

my variable (vProductSelection1) still shows "5 , 6"

How do I do this?

Thanks!

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Maybe like attached.

View solution in original post

6 Replies
swuehl
MVP
MVP

When do you want to store the values?

You can create a button to trigger writing the values to the variable in the trigger action.

sushil353
Master II
Master II

You can use input box instead of getfieldselection

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You have not said exactly when you want to store the field selections in the variable. By hardcoded I assume you mean that it should ALWAYS have this value. If so, then use the variable overview (Settings | Variable Overview) to set the variable contents and then save your document.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Well actually, my ultimate aim is to keep appending new selections to an existing bookmark without overwriting the old bookmark selections.

e.g.

(1) BM01: ProductID = { "5" , "6" }

(2) I apply BM01, and my straight table shows the corresponding values.

(3) I now select ProductID = { "8" , "9" } from my straight table

(4) I want to now be able to replace BM01 with the new selections without losing the old ones. i.e. BM01 should now save selections: ProductID = { "5" , "6" ,  "8" , "9" }.

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

As I was unable to do this, I thought of trying this instead:

(1) store BM01's selections, ProductID = { "5" , "6" }, in a variable (say v1) (somehow. I don't know how to do this yet).

(2) Select my new selection, ProductID = { "8" , "9" } from my straight table

(3) Click a button  - it will do 3 things:

     (a) set a variable (say v2) to = GetFieldSelections(ProductID)   (so its value would =  "8" , "9")

     (b) use trigger: Select in Field: Field = ProductID, Search String = v1 + v2  (with appropriate dollar-sign expansions etc.)

     (c) use trigger: replace bookmark BM01 with the current selections (which should now be v1 + v2 = { "5" , "6" ,  "8" , "9" }.)

and repeat.

Problem is that putting v2 into the Search String does not work because v2 is tied to GetFieldSelections(ProductID), which I think gets cleared when trigger (b) is actioned.

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

Any help with trying to replace a bookmark without losing the historical bookmark information (i.e. keep appending the bookmark with new selections) would be greatly appreciated.

Thank you so much!

swuehl
MVP
MVP

Maybe like attached.

Not applicable
Author

Oh wow, it works great. I spent so long trying to figure this out.

Really, thank you so much!!