cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mmattar
Level: Powered On

Changing a Form's Display mode with Switch

Hello everyone, 

 

What i am trying to do:

What i have is a form(one form) that you get too from a gallery(one gallery), but depending on condition i want to be able to edit or view form. Essitenally on the forms DefaultMode i want to have a switch statement that will be able to add my cases and within conditions get to my result of the formMode.  

 

What i have/tried:

So i tried with OnSelect of an item in the gallery to navigate to the form with params such as {displayControl: ______ } i do not know what to put in there as i get errors. I put in buttons that are clicked to get to the gallery, each button offers a different experince of the same gallery. As you can probably tell i am resuing. So when a button is clicked i have a "label" appear, so based on that label if it is visible, then assign the switch's match_result..

 

If anyone has a better soultion i would appreicate it or even helping me with what i came up with, thank you !

1 ACCEPTED SOLUTION

Accepted Solutions
TimRohr
Level 10

Re: Changing a Form's Display mode with Switch

I'm not sure what the "SS_AllTracBut" refers to in your first image, but if it is a control I don't think you're going to be able to operate your switch on it the way you want.

However, if all you need it to be is text (to be a code for testing in your Switch() statement, all you need to do is enclose it in quotation marks:

{displayControl: "SS_AllTracBut"}

 

Then you'd need the quotation marks in your Switch() statement, too:

Switch( displayControl,

    "SS_AllTracBut", ...

 

If that doesn't immediately fix what you have going on, then I think we ought to look at what you're trying to accomplish to see if there's a better way to approach it.

3 REPLIES 3
TimRohr
Level 10

Re: Changing a Form's Display mode with Switch

I'm not sure what the "SS_AllTracBut" refers to in your first image, but if it is a control I don't think you're going to be able to operate your switch on it the way you want.

However, if all you need it to be is text (to be a code for testing in your Switch() statement, all you need to do is enclose it in quotation marks:

{displayControl: "SS_AllTracBut"}

 

Then you'd need the quotation marks in your Switch() statement, too:

Switch( displayControl,

    "SS_AllTracBut", ...

 

If that doesn't immediately fix what you have going on, then I think we ought to look at what you're trying to accomplish to see if there's a better way to approach it.

mmattar
Level: Powered On

Re: Changing a Form's Display mode with Switch

this works, thank you so much

KroonOfficeSol
Level 10

Re: Changing a Form's Display mode with Switch

@mmattar

 

I know this threat was solved, but I would like to suggest another approach.

 

For what you want there are action formula, with which you can set the mode off the form.

From your gallery (so on an existing record) use

 

EditForm(YourForm)
;Navigate(YourScreen, none, {_SelectedItem:ThisItem})

From an add record button (so to make a new record) use

NewForm(YourForm)
;Navigate(YourScreen, none)

 

 

The _SelectedItem is a table variable with a snapshot off your record. You could use this as a item for you form when you are in edit/view mode. Also you can take an attribute from the variable  like _SelectedItem.ID to use in a lookup() formula to get the right record.

 

Don't forget to set the variable to blank with

UpdateContext({_SelectedItem:Blank()})

when you leave the screen. By the way, you do this on a leave button or on the Form.OnSuccess attribute.

 

I would think this is the better way to do it.

 

Hope this give some additional clearity on your question.

 

Paul

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 37 members 3,956 guests
Please welcome our newest community members: