cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to load edit form in New Form mode if gallery does not return any items

Hi,

 

I have a PowerApp screen showing a gallery and an edit form both tied to same sharepoint list, when clicked on an item on a gallery, relevant info for that item shows up on edit form, there is a '+' on top, on click of which the form loads in new form mode.

 

Now I wanna do something like, on screen load, if the gallery does not return any items, then load the form in new mode directly instead of edit mode, else part should be edit mode, can someone please help me  with formula or something, thanks in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to decide the form's mode by whether "Gallery.selected" is blank?

I suggest you not use whether "Gallery.selected" is blank as the judgment rule of  the form's mode.

Actually, "Gallery.selected" will never be blank value.

If you not select any item in the gallery and not set the gallery's default property, it will be first item by default.

If you set the gallery's default property, it will be the default item by default.

If you select any item, it will be the selected item.

I suggest you use button to decide the form's mode.

For example, if you click the arrow button inside the gallery, the form become edit form.

If you click the "+" button outside the gallery, the form become new form.

Like this:

32001.gif

 You could set the arrow button's OnSelect: 

EditForm(Form1)

set the "+" button's OnSelect:

NewForm(Form1)

 

Then the form's mode will change based on which button you click.

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
eka24
Super User
Super User

Once the gallery is directly linked to the form, there will always be items in it unless you filter the gallery to return blank. I suggest you rather insert another button and set it OnSelect to Newform(YourFormName) so that when ever you click it will be a new form. You can do same form edit form EditForm(YourFormName)
Drrickryp
Super User
Super User

Hi @Anonymous 

If your Gallery has an Items property of "MyCollection".  

Set the DefaultMode property of your Edit form to: 

 

If(!IsEmpty(MyCollection),FormMode.Edit,FormMode.New)

 

You can use the formula in your gallery's Items property instead of "MyCollection". 

v-yutliu-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to decide the form's mode by whether "Gallery.selected" is blank?

I suggest you not use whether "Gallery.selected" is blank as the judgment rule of  the form's mode.

Actually, "Gallery.selected" will never be blank value.

If you not select any item in the gallery and not set the gallery's default property, it will be first item by default.

If you set the gallery's default property, it will be the default item by default.

If you select any item, it will be the selected item.

I suggest you use button to decide the form's mode.

For example, if you click the arrow button inside the gallery, the form become edit form.

If you click the "+" button outside the gallery, the form become new form.

Like this:

32001.gif

 You could set the arrow button's OnSelect: 

EditForm(Form1)

set the "+" button's OnSelect:

NewForm(Form1)

 

Then the form's mode will change based on which button you click.

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (3,538)