Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator III
Creator III

Macro to select a specific Cycle group

i use this expression for select a specific cycle group in a macro

Set group = ActiveDocument.GetGroup("group")

group.Cycle 3

is ok, but i want to select my cycle with name not with the idorder, is possible?

i need that becouse if i select for id, never return the same cycle it depend from what cycle is selected in the moment

thanks

 

1 Solution

Accepted Solutions
Highlighted
Creator III
Creator III

Thank you, but i see the fld.name always change the values. By the way i change the solution in this mode:

set group = ActiveDocument.GetGroup("GROUPNAME")
set gp = group.GetProperties

do while activedocument.evaluate("=GetCurrentField([GROUPNAME])") <> "NAME_FIELD"
        group.Cycle 1
loop

 

View solution in original post

8 Replies
Highlighted
MVP & Luminary
MVP & Luminary

I think the following features from the APIGuide.qvw will be useful to develop an appropriate matching-logic:

grafik.png

especially those one:

rem show fields of first group in document
groups = ActiveDocument.GetGroups
set gp = groups(0).GetProperties
set vars = gp.FieldDefs
for i = 0 to vars.Count-1
set fld = vars(i)
msgbox("field " & i+1 & " is " & fld.Name)
next

- Marcus

Highlighted
Creator III
Creator III

Thanks you but it is not a solution, not resolve

Highlighted
MVP & Luminary
MVP & Luminary

You need to build the solution yourself. With the above mentioned loop it's possible to read either the index and the name of the group-fields - means picking the wanted name from there returns the index and this could be used to switch between the cyclic-fields again. Just try not directly to toggle between the fields else use msgbox to return the names and indexes to see that your logic worked and apply it then to your final macro.

- Marcus

Highlighted
Creator III
Creator III

No sorry those is not the solution, becouse if i wrote:

set vars = gp.FieldDefs
for i = 0 to vars.Count-1
set fld = vars(i)
if fld.Name="GROUPELEMENT" then
msgbox("field " & i+1 & " is " & fld.Name)
group.Cycle i+1
end if
next

it not work, becouse the group.Cycle <number> is not the ID of the group element so if i put number 5 for example in group.Cycle, i will have not GROUPELEMENT but always different group element

 

Highlighted
MVP & Luminary
MVP & Luminary

Yes, just looked in the APIGuide and it's not the group-index else the number of cycling-steps:

grafik.png

- Marcus

Highlighted
Creator III
Creator III

Yes as i said.... so how can i solve the problem?

Highlighted
MVP & Luminary
MVP & Luminary

I think the difference between the index of the active field and your wanted field should deliver the number of cyclic-steps. The above mentioned loop returned the (static) index and there you could pick the index from your wanted field and with:

groups=ActiveDocument.GetGroups
set fld = groups(0).GetActiveField

you get the active field and you could again pick this index-value - and the difference should be your value (you may also consider a possible forward- and a backward-logic - means the calculation might be different if the index from the wanted field is higher or lower as from the active field).

- Marcus

Highlighted
Creator III
Creator III

Thank you, but i see the fld.name always change the values. By the way i change the solution in this mode:

set group = ActiveDocument.GetGroup("GROUPNAME")
set gp = group.GetProperties

do while activedocument.evaluate("=GetCurrentField([GROUPNAME])") <> "NAME_FIELD"
        group.Cycle 1
loop

 

View solution in original post