web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Questions and Question...
Power Apps
Unanswered

Questions and Question Sets

(0) ShareShare
ReportReport
Posted on by 26

This is a "how to", rather than a question.

 

I recently had the need to create a survey that would display different questions depending on a parameter passed in a URL (if launching from a "deep-link"), or display the app in Teams (where you can't pass parameters).  So, if the app is running in a browser, you get the survey with the right questions.  If the app is running in Teams, you land on a different screen (for editing survey responses and providing response metrics).

 

There are three main difficulties to overcome:

1.  Conditional navigation isn't allowed in an App OnStart property, making it difficult to jump to the right screen depending on whether or not the parameters exist.

2.  You need to have a menu that exists on all of the question pages that allows you to navigate to any questions in the selected question set (since the question set would be different, depending on the parameter received).

3.  While it's easy to "direct code" a table to act as a list of questions to ask, by using a "question set" (retrieved from Dataverse), you can't direct-code the table or collection.  It has to be built "on the fly" based on whichever question set is selected in the URL.

 

Doing this required the combination of different sources of help:

#1 was overcome by using a trick.  See Re: Why we can not use Navigate() in OnVisible - Page 2 - Power Platform Community (microsoft.com).  In my comment there, see how to use a "mode" screen with a timer control to choose which screen to start on.

#2 was overcome by implementing a "Sidebar Menu Component" (except for the problem in #3).  See Matthew Devaney's excellent post at Power Apps Navigation Menu Component - Matthew Devaney

#3 was overcome by creating a couple of tables in Dataverse, along with some code on the SurveyStart page OnVisible property:

 

The first Dataverse table, "ThreatConQuestionSets":

Has a QuestionID (text), QuestionSetName (text), TCQuestions (same as QuestionID, but has a lookup to the other table), SetID (text)

 

The second Dataverse table, "ThreatConQuestions":

Has a QuestionID (the lookup destination for TCQuestions in the other table, which is also the screen name of that question), Icon (for displaying in the menu component), and a Question column (which is unused, but helps me remember what the actual question is for any QuestionID)

 

Set(vSetMembers, Filter(ThreatConQuestionSets, SetID = vName)); //vName is a global variable defined from the parameters in my post (#2 above)
ClearCollect(ColSetMembers,vSetMembers.QuestionID);
ClearCollect(ColSetMembers2,AddColumns(ColSetMembers, "Icon", LookUp(ThreatConQuestions, QuestionID = ColSetMembers[@QuestionID], Icon)));
Clear(ColSetMembers3);
ForAll(ColSetMembers2,Collect(ColSetMembers3,Last(FirstN(AddColumns(ColSetMembers2,"Value",CountRows(ColSetMembers3)+1),CountRows(ColSetMembers3)+1))))//The "CountRows functions on the end create a sequential number (text) column so that the questions are numbered "1,2,3,4...", regardless of which actual question numbers they are.
Set(ColSetMembers4,RenameColumns(ColSetMembers3,"crb38_name","Screen"))//Note that your name column won't match mine
ClearCollect(ColSidebarMenu,
    ForAll(ColSetMembers4, {Value: Value, Icon: Icon, Screen: Switch(Screen,"q-1",'q-1', "q-2", 'q-2', "q-3",'q-3', "q-4", 'q-4',"q-5",'q-5', "q-6", 'q-6', "q-7",'q-7', "q-8", 'q-8',"q-9",'q-9', "q-10", 'q-10', "q-11",'q-11')}))  //The Switch function is necessary here because you can't navigate to a text value from the collection.  Instead, you have to navigate to a screen control.  The ones with double-quotes are the text values in the ColSetMembers4 collection.  The ones with single-quotes are the screen controls that end up in the ColSidebarMenu collection.
 
Note that you have to hard-code the number of possible questions in that switch statement.  My surveys would not have more than 11 questions (if you selected the "allquestions" setID in the URL).  Each screen (such as 'q-7') contains a label for the question, and you can patch the responses back to a Dataverse table along with the surveyID (another URL parameter) and the QuestionID.  This other parameter allows you to later match-up responses with which survey they were received from.
 
One other tip:  When you're entering the icon values in your Dataverse table, the icon names are not what you expect (not what is displayed in PowerApps).  For example, if you want the Question Mark icon, it's not "icon:QuestionMark".  It's "builtinicon:QuestionMark"
 
I know this post isn't detailed enough to walk through creating the entire app, but hopefully it's enough to get you started if you want to make something similar.  Enjoy!  😁
Categories:
I have the same question (0)
  • Verified answer
    Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @korebreach - thanks for this. Have you considered creating a post on the Community Blog?

     

    https://powerusers.microsoft.com/t5/Community-Blog/ct-p/PA_Comm_CommunityBlog 

     

    I would recommend reaching out to @heaher_italent or @DuaneM_iTalent to obtain approval for creating Community Blog posts.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard