cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Steven_Ross_Lee
Helper I
Helper I

Setting 2 variables, with Button onSelect, on a multi-form, multi-tab, screen

I have one screen in Powerapps which has multiple forms for a Client. Each of these forms are connected to a different CDS entity (table) of information about the same Client. I also have a set of buttons that represent Tabs for the various forms that the user can view/edit. On this one screen, I have Icons in the top banner to represent New, Cancel, and Save fuctions for any of these forms.

 

I want the OnSelect function of the Buttons(Tabs) to set two variables. One to be used by each form's Visbible property, so that it is the form visible when clicked. But, at the same time, I want to set a second variable that equates to the form name so that, when the user clicks the New/Cancel/Save Icons in the top banner, it will perform the correct action for the correct form.

 

So far I have tried using 2 Global variables in the OnSelect for the buttons, 2 Context variables, and have tried mixing Global with Context variables. Nothing yet has met the requirement. I either get errors on the buttons or errors on the New/Cancel/Save Icons.

 

I have included a picture (minus the actual form fields) of the set-up.

Has anyone tried to create the exact same configuration? Am I dealing with a limitation or bug in PowerApps?

Any help is greatly appreciated

 

Thanks,

Steve

12 REPLIES 12

@Steven_Ross_Lee 

No problem with the data source.  That's not an issue here.

 

As for the other point, with a Gallery in place you definitely have less controls to deal with and you can confine your formulas to single areas when needed (much easier to troubleshoot).

 

Let's imagine for a moment that you have a horizontal Gallery (let's call it galFormSelect) with one button in it.  The Items Property of the Gallery might be something like this:

Table(
{btn:"General", ID:1},
{btn:"Contact", ID:2},
{btn:"Dues", ID:3},
{btn:"Appointment",ID:4},
{btn:"Matters", ID:5},
{btn:"Communication", ID:6},
{btn:"Academic", ID:7},
{btn:"Salary", ID:8}
)

The visible property of each EditForm might be like this. 

    Contact Form -  Visible : (galFormSelect.Selected.ID = 2)

    Dues Form - Visible : (galFormSelect.Selected.ID = 3)

    etc...

 

The Save control would have a formula similar to this:

Switch(galFormSelect.Selected.ID,
1, SubmitForm(GeneralForm),
2, SubmitForm(ContactForm),
3, SubmitForm(DuesForm),
4, SubmitForm(AppointmentForm),
5, SubmitForm(MattersForm),
6, SubmitForm(CommunicationForm),
7, SubmitForm(AcademicForm),
8, SubmitForm(SalaryForm)
)

This would give you the same functionality just with a Gallery as your control.  If you're using button in your Gallery, you don't even need to put any formulas in it.  It will automatically have Select(Parent) which will do the "selected" for you and meet all the other formulas.

 

I hope that is clear and helpful.  Post back if you have more questions.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

I have replaced the buttons with a gallery, and totally see your point. It's working with my IF statements on the Control, but I will change it to the Switch function you have illustrated.

 

Thanks for all your help Randy. You've been great.

 

/Steve

@Steven_Ross_Lee 

No problem!  Yes, If statements will work, but I personally find a Switch statement to be much cleaner and easier to diagnose and read.

Good luck with the rest and definitely post back if you have issues.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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,142)