cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ahveron
New Member

Form submits blank records

Hello Everyone!

 

I have another problem, and I am quite lost. I have a form (It's defaultmode:If(true,FormMode.New,FormMode.Edit)) and when I try to submit it with SubmitForm(), it creates a blank record. The datasource is in CDS, and I have datacards, with the right datafields(when in edit mode, it shows the right value for the item I selected), and with text input, all of them has values, when I submit it. The update property is set to DataCardValue1.Text. (I select the item with a gallery on a previous screen, if it is in edit mode). Does anyone encountered previous problems before? I have spent the last 8 hours with this problem, and I have no clue.... Oh, and sorry if it has been answered before, I could not find a solution which worked for me here.

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User III
Super User III

Hi @Ahveron 

Thanks for the clarification. To progress this, I would suggest that you try to get the form working in edit mode first. Once this works, I would work on changing it so that it works in new mode also. Here are the things I would do to ensure that the form works in edit mode.

 

- Set the default mode of your form to FormMode.Edit
- Make sure that you've set the data source of your form to your CDS entity
- Set the item property of your form to the selected item of your gallery (for example, BrowseGallery1.Selected)
- In your edit form, click the edit fields link, and delete and re-add cards for your fields. This will reset the controls and the update properties for each card.

timl_0-1604780769479.png

 

- In the button where you call SubmitForm, make sure that you're passing the correct name of your form.

If you make the above changes, does the form correctly save your record?

View solution in original post

5 REPLIES 5
timl
Super User III
Super User III

Hi @Ahveron 

To clarify, are you saying that when you attempt to edit an existing record, the form creates a blank record instead?

If you've set the default mode to the following formula, the form will always be in New mode (because the condition is hard coded to true).

If(true,FormMode.New,FormMode.Edit)

If you modify the form mode property to FormMode.Edit, does that fix your problem?

The following link in the documentation might be of use to you. It explains how you can call the EditForm and NewForm functions to change the form mode.

https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-form

 

Oh, no, when in new mode, it creates a blank record. When in edit mode, it simply does not change anything... I don't know why I wrote the if like that. In the app it is If(isnewinput,FormMode.New,FormMode.Edit), where Isnewinput is a boolean, which is set to true, if the user presses the add new input button, and set to false, if he presses an icon in one of the items in the gallery. Sorry, I was quite misleading with the wording there.

Oh, @timl, and another bit of info, maybe it helps: I have a button in the galllery which deletes the selected record, and that one is working properly.

timl
Super User III
Super User III

Hi @Ahveron 

Thanks for the clarification. To progress this, I would suggest that you try to get the form working in edit mode first. Once this works, I would work on changing it so that it works in new mode also. Here are the things I would do to ensure that the form works in edit mode.

 

- Set the default mode of your form to FormMode.Edit
- Make sure that you've set the data source of your form to your CDS entity
- Set the item property of your form to the selected item of your gallery (for example, BrowseGallery1.Selected)
- In your edit form, click the edit fields link, and delete and re-add cards for your fields. This will reset the controls and the update properties for each card.

timl_0-1604780769479.png

 

- In the button where you call SubmitForm, make sure that you're passing the correct name of your form.

If you make the above changes, does the form correctly save your record?

View solution in original post

Thank you very much! It worked. I think the problem was with my renaming of datacardvalue-s. But, it is solved now! 🙂

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (58,851)