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

Submitting a form is editing a record? PowerApps for Dummies issues...

I know this is probably the stupidest thing, but here I am.

 

I have a Flow that is set to trigger when a NEW item is added to a Sharepoint list. It has worked in the past so I know the flow isn't the issue. I have a PowerApp Form set up to add items to the list. However, for some reason when a user selects the SUBMIT button, it EDITS whatever the most recently added list item was vs adding a NEW list item. Button code is OnSelect:

SubmitForm(SharePointForm1);

 

Here's what I want to happen fully, if you have insight into other issues because I have watched so many videos and read so many threads and am still feeling like an idiot!:
1. When the user clicks on a list item, I want the list item to open in View mode (right now it opens as a blank new form). If I click item > details I can see the info, but then if I click "edit" i get a blank form vs the filled in info to edit.
2. After SUBMIT/save of new item, I want the form to close and for the user to return to where they were (popup to close).

3. I would like for the form to be in a pop up/modal, as most users don't have access to the full list so cannot use the +new button.

5 REPLIES 5
Eelman
Community Champion
Community Champion

@jenw 
SubmitForm() runs a check before it submits data. This check is like an If() statement. The thing it checks for is the state of the form --- either Edit or New. If the form is in Edit Mode it updates the record that has been given to the form and if it is in New Mode it adds a new record to the data source.

 

To me, it sounds like your form is in Edit Mode, hence why it's updating and not adding.

For me, I found a good way to learn how forms work is to make a basic mobile app and let PowerApps build the 3-screen app for you. Then, inside the app, have a look at the code that runs the New item (+) and Edit item (pencil icon) processes. The + icon runs code like NewForm(Form1)... and the pencil icon runs code like EditForm(Form1)...

 

Other key parts include setting the Forms' DefaultMode to 'Edit' and its' Item (most times) to the one selected from a gallery. After Submit you should also run ResetForm().

 

Apologies if you already know all the above but I'd be looking into your Forms' state to solve the issue you are having.

WarrenBelz
Super User
Super User

Hi @jenw ,

Firstly a couple of things to check before any "deep diving". I will cover your three questions first.

Question 1:
I assume you are clicking from a gallery to the form. I will assume screen navigation (I called it Screen2 below), but you can leave that out if not applicable.

Firstly, the DefaultMode of SharePointForm1 should be FormMode.View if you want it to open in that manner. You can also force this in the OnSelect transition from the gallery  (but should not have to) from the gallery with something like:-
Navigate(Screen2,ScreenTransition.None);
ViewForm(SharePointForm1)

It sounds like the the form is being opened in New mode (or has that set as a default)

 

Question 2:
You have not said how the pop-up opens (or is it a new screen?) If a new screen, just add Back() to the submit

SubmitForm(SharePointForm1);
Back()

If you want to go to another screen, add navigation to it as in Question 1

 

Question 3:
There are a number of ways of doing this, the most common of which is a form "in the front" (or overlayed), but only visible when a variable is set to true. Also generally included is a semi-transparent Fill of RGBA(168, 168, 168, 0.75) rectangle just behind it covering the full screen so nothing else can be clicked while it is open. You also need a close X icon on the rectangle or form.

So using your form name, the Edit button would do something like (use any variable name you want):-

UpdateContext({vEdit:true});

EditForm(SharePointForm1)
The Visible property of the Form, Rectangle and Exit icon would be vEdit and the OnSelect of the Exit icon would be UpdateContext({vEdit:false}), which would cause the "pop-up to disappear.

That is probably enough info for you to absorb - let me know how you go.

 

 

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up.

jenw
Frequent Visitor

Thank you for your responses! I thought the form Default mode might be part of it, so I have messed with that. Right now it's set to VIEW. But still.....why is it opening to a NEW BLANK form instead of the item's data in edit mode? Additional details per questions: There will be a left sidebar link for most users that will only be used to submit a NEW form. This would pop up over...whatever screen they are on and when closed would close to whatever screen they are on. This will not be used mobile. Desktop only. Getting the popup to work is last priority - previously I had it set up that for users who clicked the left sidebar link it opened the form in a new tab. Then yes, if a user goes to the list and clicks on a list item, it should open in either VIEW or EDIT (either would be ok, really). I have added no special behavior code other than trying to get this to work, so it frustrates me that what seems to be the obvious way it should work OOB is...not.

Hi @jenw ,

 

Will get back to you tomorrow. (About 8 hours) Late night here in Oz

Hi @jenw ,

I am guessing a bit here without have an app to debug, however there are a few settings you might look at for your rogue code.

The first would be the OnVisible property of the screen as this will override anything done before transition.

Sorry if the next two are obvious, but check the Items property of the form - it would be <YourGallery>.Selected - and its DataSource.

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

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.

Users online (2,097)