I have decoupled my forms from a gallery I use to select a customer from a list. So I select the customer in a gallery - click edit customer button and it navigates to a new form.
The form Item is set as a variable instead of the selected item from the gallery. Yes it is the same ID but it is decoupled via the variable so that SubmitForm does not reset my currently selected customer as it is still stored in the variable.
This is all good until I click on the New customer in my starting form where my gallery is. If I do this it goes to the form but it does 1 of 2 things. If I have not chosen a customer and edited it - which populates my variable - then the variable will be empty and it shows the message - no items to display. If I have edited an existing customer then the variable is populated and it will show that customer instead of a blank screen.
THis is from the help:
The NewForm function changes the Form control's mode to FormMode.New. In this mode, the contents of the Form control's Itemproperty are ignored, and the default values of the Form's DataSource property populate the form. If the SubmitForm function runs when the form is in this mode, a record is created, not changed.
THis tells me it should be going into FormMode.New but it does not seem to be happening.
I place a label on the screen and set its text to Form.DisplayMode. If I go in via EditForm or NewForm it always shows the value as Form.Edit.
Why would it not be switching over to Form.New??????
I noticed that in the form the DefaultMode is set to FormMode.Edit. I tried changing this to FormMode.New and it will only take me to a new form with that setting.
I suppose I could create a variable when I click the Edit or New button and then OnVisible of the next screen but this seems wrong as it should be working like the help says.
The form’s mode is set in the button or icon’s OnSelect property used to navigate to your form. use EditForm(Form1);Navigate(Screen1,None) to set the mode for your form to Edit (replace Form1 and Screen1 with the name of your Form and Screen respectively) and NewForm(Form1);Navigate(Screen1,None) to set the mode to New.
yes - I know this. That is exactly what I am doing but it is not working.
Edit button : OnSelect - I do not set to editform as the default is set to Edit.
New Button: OnSelect
Just a small point but when i decouple forms from galleries, I make the form's Item property - Lookup(datasource,ID = Gallery.Selected.ID) or in your case Lookup(datasource, ID=SelectedCustomer.ID). I'm not sure if that would help but it couldn't hurt to try it. I do this because then you can use a collection for the gallery's Items property and still modify the datasource using a form. The datasource in the Lookup() must be identical to the datasource property of the form or it will throw an error.
I looked at this video and the Mode option was new to me.
So I tried adding a label and using FormName.Mode gives an error
The property expects Text values, but this rule produces incompatible ENUM values.
I thought it might be something in my app so I created a new one with 1 form and the label - same issue.
If I change it to Formname.DisplayMode it works fine. Possibly something wrong with Mode???
At this point I am working around this with a variable that I set and an If statement to force the FormMode to .Edit or .New
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!