cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
casperbr
Frequent Visitor

Variable sequence of screens

Hi all,

 

I want to build this app where there are a couple of Screens, let's say: Main, A, B, C, D, E , F, G, H.

In the main you have to select (from a gallery eg)  a Situation which requires a combination of the other Screens. So in Main I select Situation 1 which requires the app to go through Screen A, B & F (not the others), but if I select Situation 2 the app should go through Screen B, F,G & H. Then there is also Situation 3 where you should only go through Sceen D, you get the point.

 

(In all screens there are some checklists and in the end I want to add a results screen with a submit button something like that.)

 

I was thinking about adding a column to the data source where a sequence of screen is listed for every row/situation. The app would read the sequence and go through the corresponding screens. However I don't really know how to translate a list of numbers to a sequence to follow.

Also when I try to create a "variable" Navigate button that I want to use to navigate to the Screen corresponding to the selected Gallery item I don't know how to translate an item to a screen:
Something like: Navigate(Gallery1.Selected.Screen) doesn't seem to work...

 

What are your thoughts? Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
casperbr
Frequent Visitor

Okay guys I came up with the following (an example with just  4 Situations and 6 Steps):

 

For every Situation I import an "Array": one excel with x number of tables (for every situation one) with 2 columns. 1 column for Index and the other for the Screens to navigate to, like this:

Situ1

IndexStep
12
23
35
46

In the main Screen, where the users selects a Situation. The Situation is selected from a Gallery which uses a Table for Items. This table looks something like this:

 

Table(
    {Situ: 1, Table: Situ1, Text: "Situation 1"},
    {Situ: 2, Table: Situ2, Text: "Situation 2"},
    {Situ: 3, Table: Situ3, Text: "Situation 3"}, 
    {Situ: 4, Table: Situ4, Text: "Situation 4"}
    )

 

Where column Table is linked to the loaded tables, so in a way the corresponding sequence is loaded.

 

Now I also defined a Counter, which counts in what step you are. So when you click on next after selecting a Situation it is on 1 for the first step. I use the LookUp function with the Counter on the loaded Situ1 table to mimic indexing and finding the correct Screen to navigate to. In every screen clicking Next will increase Counter and clicking Back will also reduce Counter. Clicking on Home will reset Counter to zero.

 

The navigation button will look like this:

 

Set(NextScr, LookUp(VarNav, Index = Counter).Sit);
Switch(NextScr,
    1, Navigate(O_1),
    2, Navigate(O_2),
    3, Navigate(O_3),
    4, Navigate(O_4),
    5, Navigate(O_5),
    6, Navigate(O_6)
);
Set(Counter, Counter+1)

 

 

The tables that are loaded with the sequences can easily be modified when the order of the screen would change, so it is flexible.

The only problem is that in reality I got many more Steps (like 50 but it might increase) and there are more Situations, so the two parts of code I post are much larger.

 

What do you think of this solution? I like the logic, but it might not be the prettiest because of the abovementioned size of the app.

Any advice or comments? Your previous comments already helped a lot!

View solution in original post

9 REPLIES 9
BCLS776
Super User
Super User

Try this:

  1. Use your code to set a global variable to your "situation number", e.g. Set(varSituation, 2)
  2. Use a Switch statement when you are navigating to decide which screen to advance towards:
Switch(varSituation,
    1, Navigate(Screen1),
    2, Navigate(Screen2),
    3, Navigate(Screen3)
)

Hope this helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
casperbr
Frequent Visitor

Yeah that's great I think that this already really helps!

However it gets tricky with the specific sequence of screens. You could ofcourse hard code per screen for every situation which would be the next screen, but there are 11 situations and the order of the screens might change so that would be a pain to change per screen.

That is why I was thinking of using a sequence of numbers in the first screen so you will be able to adjust just that sequence and you will be good. You understand what I mean?

I already tried something, but I came up with a string with some number which then you should split and convert to a number for the set input. but hten you also have to "remember" what place you are in the string per screen

logixcrm
Helper I
Helper I

Hi @casperbr 

 

Perhaps you could consider creating a variable of type Array to hold the sequence. As the user enters information on the home screen the Array is composed. This way as the user navigates through the screens you can use the index number of the Array to decide which screen to go to. 

 

Another solution, which I would probably prefer is to use Flow. I would configure the branching rule in Flow using a condition action. Remember, the Flow can take inputs from the canvas app and respond back. The response back can trigger a navigate action.

 

This is a little tricky since you are trying to build branching rules. I had a similar situation with another app and I ended up adding layered buttons which each had different navigation settings, nasty I know, but it worked for that specific situation.

I don't like big, hardcoded Switch() statements either, but Power Apps is limited in how it can dynamically assign data to things like screen control names.

 

To implement the scheme I suggested, you have to carefully set up a Switch on each button (or other control) that initiates navigation to the next screen in the sequence. It will be a tough one to test and maintain, but I think it is the only way you are going to achieve this user interface journey.

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
zmorek
Super User
Super User

It's not an answer to your question, but on the same topic - have you tried taking a look at all the different situations/screen combinations to see/ensure that they actually "need" that many combinations? Perhaps reviewing via some sort of flow chart might reduce the number of situations.

casperbr
Frequent Visitor

I made a flow chart like overview and yeah this is the most efficient way to do it

I do like this array idea, however there is no Array type in PowerApps right? Do you suggest working with a Table? What is the best way to index?

logixcrm
Helper I
Helper I

Hi @casperbr 

 

I have done some testing and I see why you are having an issue, it seems trying to navigate to a Variable may not be possible, however, I have created test application to simulate branching as per the picture below. I have not used Flow, Variables or Arrays, just simple if statements.

 

I have also included the canvas app which you can install to see how i configured the application.

 

Branching Diagram

logixcrm_0-1632924066792.png

 

casperbr
Frequent Visitor

Okay guys I came up with the following (an example with just  4 Situations and 6 Steps):

 

For every Situation I import an "Array": one excel with x number of tables (for every situation one) with 2 columns. 1 column for Index and the other for the Screens to navigate to, like this:

Situ1

IndexStep
12
23
35
46

In the main Screen, where the users selects a Situation. The Situation is selected from a Gallery which uses a Table for Items. This table looks something like this:

 

Table(
    {Situ: 1, Table: Situ1, Text: "Situation 1"},
    {Situ: 2, Table: Situ2, Text: "Situation 2"},
    {Situ: 3, Table: Situ3, Text: "Situation 3"}, 
    {Situ: 4, Table: Situ4, Text: "Situation 4"}
    )

 

Where column Table is linked to the loaded tables, so in a way the corresponding sequence is loaded.

 

Now I also defined a Counter, which counts in what step you are. So when you click on next after selecting a Situation it is on 1 for the first step. I use the LookUp function with the Counter on the loaded Situ1 table to mimic indexing and finding the correct Screen to navigate to. In every screen clicking Next will increase Counter and clicking Back will also reduce Counter. Clicking on Home will reset Counter to zero.

 

The navigation button will look like this:

 

Set(NextScr, LookUp(VarNav, Index = Counter).Sit);
Switch(NextScr,
    1, Navigate(O_1),
    2, Navigate(O_2),
    3, Navigate(O_3),
    4, Navigate(O_4),
    5, Navigate(O_5),
    6, Navigate(O_6)
);
Set(Counter, Counter+1)

 

 

The tables that are loaded with the sequences can easily be modified when the order of the screen would change, so it is flexible.

The only problem is that in reality I got many more Steps (like 50 but it might increase) and there are more Situations, so the two parts of code I post are much larger.

 

What do you think of this solution? I like the logic, but it might not be the prettiest because of the abovementioned size of the app.

Any advice or comments? Your previous comments already helped a lot!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,326)