[Solved] How do I get a list of all question IDs for a survey?


I see that there is an allquestionsoftype(type, pageID) function available.  Is there something similar to get a list of all questions within a survey–or at least a page?

I need to hide and/or set the certain properties conditionally for all questions in the survey and I’m hoping that I can avoid calling allquestionsoftype() once for every type.


Brian J.

Brian90 selected answer

    Best answer


    I found a better solution for grabbing all of the question IDs from a survey.  I’m posting an answer in case anyone else runs into the same situation:

    The pagemap() provides a list of pages and the top level array has an ordered index.  However, the indices for the subsequent question types are keyed by the question ID.  Therefore, obtaining the pagemap() and looping through the keys inside each page will do the trick.


    For example, here is a portion of a pagemap():

        [1] => [ 
                [356] => INSTRUCTIONS 
                [300] => INSTRUCTIONS 
                [489] => SCRIPT 
        [2] => [ 
                [1] => INSTRUCTIONS 
                [487] => SCRIPT 
                [355] => INSTRUCTIONS 
        [3] => [ 
                [11] => SLIDER 
                [15] => SLIDER 
                [59] => INSTRUCTIONS 
                [10] => SLIDER 
                [490] => SCRIPT 
                [14] => SLIDER 
                [9] => SLIDER 
                [315] => INSTRUCTIONS 


    While the key/index at the top level is ordered (1, 2, 3, …), the keys inside each page are the question IDs (356, 300, 489, …).  Therefore, if you just make a nested for loop, it’s pretty easy to construct a list:

    Brian90 edited answer

      It’s not related to scripting but perhaps the survey legend tool will be helpful:


      You might also consider exploring the API to pull this information on a per page basis:


      Hope this helps!

      Brian90 commented
        • Thank you for the links, but I’m afraid they will not help for the embedded Lua scripts. The API works great for communications between SG and our internal software, but I am looking for a way to access this within the embedded Lua scripts.

          There is a work around, however. I can grab the pagemap() and then filter for a set of (unique) question types on the current page, then call allquestionsoftype(type, page) for each type found on the page. However, this seems like one heck of a work around just to get a list of questions on the page of a survey.

          I’m really hoping that a standard function will be implemented and documented if this truly is the only way to get all of the questions on a page.



        Question stats

        • Active
        • Views2017 times
        • Answers2 answers
        • Followers1 follower