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

Getting Selected Values and Selecting them in other field

Sorry I am not good enough to solve this, my goal is to switch from one date field to another while keeping the selections (i.e. byInvoiceDate vs. byOrderDate) I need to read the selected values on one field and apply them on another, then I clear the first one. Obviously the selection can include more than one QTR or Month, anyway the GetSelectedValues returns an array and you cannot just use A.text to pass it ...

Problem is that if I do it with the FOR only the last value of the array gets re-selected overwriting any previous selections that were applied in turn, I cannot find a way to use the Select directly with the object A as an array.

Any advice? 😉

Flavio


set A = doc.fields("Quarter").GetSelectedValues
for i = 0 to A.Count - 1
doc.fields("Quarter2").Select A.Item(i).text
next
doc.Fields("Quarter").Clear


Federico Sason | Emanuele Briscolini
1 Solution

Accepted Solutions
prieper
Master II
Master II

Dear Flavio,
think that a macro similar to the attached file should solve your problem

Have Fun!
Peter

View solution in original post

4 Replies
Not applicable

Use ToggleSelect

eiconsulting
Partner - Creator
Partner - Creator
Author

I cannot see how, for what API Guide tells ToggleSelect is a function to select field values matching a given string.

I don't have a string, do I have to transform my object A into a string and then apply that to the xx.Select?

I have specific values inside a variable (object A) and want to write them into a new field. I need to use xx.Select with an array instead of a single value. Or in a way that is cumulative. I even tried xx.Select.Add ...

Flavio

Federico Sason | Emanuele Briscolini
prieper
Master II
Master II

Dear Flavio,
think that a macro similar to the attached file should solve your problem

Have Fun!
Peter

eiconsulting
Partner - Creator
Partner - Creator
Author

Actually your solution was SO INTENSIVE that I used only your last line. SUPER!

Instead of using xx.Select ... xx.SelectValues allows me to set an array in one shot. I'll try more exensively to see if i have to use the whole code but this appear really to be it.

[code/]

set A = doc.fields("Month2").GetSelectedValues --- gets the selections from Month2
doc.fields("Month").SelectValues A --- sets the selections on Month
doc.Fields("Month2").Clear --- clears the selections on Month2 to make it ready for next toggle

Many thanks

Flavio

Federico Sason | Emanuele Briscolini