Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Load all fields of a data table in a Multibox

Hello to everybody

Could someone please help me solving the following problem.

I built an application which bases on three data tables (Customer, Transactions, Products). The names of these data tables are fix. But the number and some names of the fields change over time.

I would like to automate that all fields of a data table (Customer) are loaded in a multi box and / or in a cycle group.

How can I solve that?

- In a macro?

- In the load script?

Could you please assist me in designing the necessary code?

Thanks very much

Best regards

Lukas

1 Reply
Not applicable
Author

No ideas I could manage this?

I am trying to find a solution for about 2 days; actually without any success (I am a little bit new to Macros).

I found a code to automatically add fields to a group. But I still don't know how to loop over a certain data table and get all field names

sub add_Group

     ' -----------THIS DOES NOT WORK: Loop over a data table and get all field names; ANY IDEAS HOW TO SOLVE THAT?

    FOR vColumnCounter = 1 TO NoOfFields("MyTable")

          set vFieldName = FieldName(vColumnCounter, vTableName) 

          call Add_grp(vFieldName)

    NEXT

end sub

' -----------THIS WORKS: Adding fields to a group

sub Add_grp(field)

set group = ActiveDocument.GetGroup("NameOfTheGroup")

set gp = group.GetProperties

set vars = gp.FieldDefs

for i = 0 to vars.Count-1

    set fld = vars(i)

    if field = fld.name then

     counter = 1

    end if

next

if counter = 0 then

group.AddField field

msgbox field &" is Added to Group"

end if

end sub

Thanks

Lukas